# I am trying to create a custom calculation to determine if the peak area of an unidentified peak is >= the peak area of a compound in a standard run (reporting limit criteria).

As stated in the title, I'd like to determine if the peak area of an unidentified peak is >= the peak area of the reporting limit standard. I'm using the CCs below and it will only report the results for the identified compound. How do I get this calculation to be reported for all integrated/unidentified peaks?

1. Determine what is the last checked reporting limit standard was. (LastCheckRLSTD)

If(CurrentSample.Sample_Type<>15, CurrentSequence.AllSamples.Where(function(y) y.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).Where(function(y) y.Sample_Type=15).Select(function(y) y.Sample_Name).Last, "N/A")

2. Index the peak area of the compound peak in the reporting limit standard. (LastCheckRLSTDPeakArea)

CurrentSequence.AllIdentifiedPeaks.Where(function(y) y.Injection.Sample.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).Where(function(y) y.Injection.Sample.Sample_Name=LastCheckRLSTD).Where(function(y) y.Compound_Name=CurrentPeakOrGroup.Compound_Name).Select(function(y) y.Peak_Area).Last

3. Determine if the peak area of an unidentified peak is greater than the peak area of the reporting limit standard.

If(Compound_Name="", If(Peak_Area > LastCheckRLSTDPeakArea, "Met", "Unmet"), "N/A")

Any help is greatly appreciated.

• Hello,

Are you trying to compare the unknowns to a specific named compound area in the Spike samples?  You are combining AllIdentifiedPeaks with "Where(function(y) y.Compound_Name=CurrentPeakOrGroup.Compound_Name" if you are doing this calculation at peak scope then you will not get any results for unknowns. Even if you had done allpeaks it would have compared all the unknowns to the last one in the chromatogram.

Try this at a peak or group scope and type of string. You will need to change the compound name to the name of the compound you test the unknowns against.

If(Compound_Name.Length > 0, "N/A", If(Peak_Area > CurrentSequence.AllIdentifiedPeaks.Where(function (x) x.Injection.Sample.Sample_Type = 4).Where(function (x) x.Compound_Name = "Peak C").Where(function(y) y.Injection.Sample.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).OrderBy(function(x) x.Injection.CreationTime).Select(function(x) x.Peak_Area).Last,"Met","UnMet"))

• Hi Marty,

I am indeed trying to compare the unknowns to a specific named compound area in the Spike samples. I'm using the "Spike" sample type to identify our reporting limit standard (our standard compound at a low concentration which demarks our reporting criteria).

Thank you for pointing out how I might be limiting the CC to only identified compounds. Admittedly, I've been reusing chunks of CC code written by other people to make my own work as intended. I don't fully understand much of the LINQ syntax and that has really limited my abilities.

I tried the code you suggested with small modifications and it still only reported this CC for identified compounds. For identified compounds, the code worked as intended and the string "N/A" was reported. What is the function of calling out Compound_Name = "Peak C"?

Modified form of the code you suggested:

If(Compound_Name.Length > 0, "N/A", If(Peak_Area > CurrentSequence.AllIdentifiedPeaks.Where(function (x) x.Injection.Sample.Sample_Type = 15).Where(function (x) x.Compound_Name = "Peak C").Where(function(y) y.Injection.Sample.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).OrderBy(function(x) x.Injection.CreationTime).Select(function(x) x.Peak_Area).Last,"Met","Unmet"))

• Hello,

Sorry, I was not more precise in the first reply. You need to change "Peak C" to the name of the peak in your Spike samples that you want to compare against. You can use like and wildcards if you do not want to type the entire name. You could also do .ToUpper if you wanted to make it case insensitive, but the example CC is the simplest format. For the example the name must match exactly the compound name in the method.

If(Compound_Name.Length > 0, "N/A", If(Peak_Area > CurrentSequence.AllIdentifiedPeaks.Where(function (x) x.Injection.Sample.Sample_Type = 4).Where(function (x) x.Compound_Name = "Your Peak Name Here").Where(function(y) y.Injection.Sample.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).OrderBy(function(x) x.Injection.CreationTime).Select(function(x) x.Peak_Area).Last,"Met","UnMet"))

• You're a saint and a scholar. It worked!

• One more question about LINQ syntax. I'd like to call the "Sample amount" for the last checked calibration standard. I used the same code, more or less, and receive that error that sample_amount isn't under peak/group. It isn't clear to me how I should change this to select that field. Do I need to start from AllInjections instead of AllIdentifiedPeaks?

CurrentSequence.AllIdentifiedPeaks.Where(function (x) x.Injection.Sample.Sample_Type = 5).Where(function (x) x.Compound_Name = "Confidential").Where(function(y) y.Injection.Sample.Sample_OrderNumber<CurrentSample.Sample_OrderNumber).OrderBy(function(x) x.Injection.CreationTime).Select(function(x) x.Sample_Amount).Last

• Yes, you will want to start with AllInjections and you can also remove the compound name where clause. I would also change the scope to injection. 