2 Replies Latest reply on Jan 23, 2019 5:27 AM by camelia

    Sum Conc A and Conc B if Conc A not present



      I have created the following CC in order to calculate 70% of Peak A + Peak B


      IF both Peak and Peak B are present this works, however, it only works if  Peak A and Peak B are present which isn't always the case.

      How can I modify the expression so it outputs a result even if Peak A is not detected/integrated?

      I have also tried using the intelligent reporting to achieve the same calculation using variables and aggregators and I have the same problem in that both peaks need to be present for the sum to work and output a value.

        • Re: Sum Conc A and Conc B if Conc A not present

          Hello camelia,


          I added tags to this post to increase visibility.


          One way to address this would be to set up a custom calculation to identify missing compounds for a given injection/signal. The below formula will output "No Calibrated Peak(s) Missing" if no missing compounds are identified. If missing compounds are found, then the formula will output "Fail" followed by a list of the missing compounds for the loaded signal:


          If (Count(CurrentSignal.AllMissingCompounds) = 0, "No Calibrated Peak(s) Missing ", "Fail " & string.join(" ",CurrentSignal.AllMissingCompounds.select(function(x) x.Compound_Name.tostring())))


          In my CC File, I used an Identifier of "MissingCompounds" for the CC using the above formula. I then created a CC identified as "CompoundA" to check if "Compound A" was found by the MissingCompounds CC to be missing. If so, it will output a value of 0 while if Compound A is not missing then Compound A's concentration will be outputted. Below is the formula for the "CompoundA" CC:


          If (InStr(UCase(MissingCompounds), "COMPOUND A") > 0, 0, CurrentSignal.PeakOrGroupByName("Compound A").Compound_Concentration)


          You can set up a similar CC to do the same for Compound B, like below (using "CompoundB" as the CC identifier):


          If (InStr(UCase(MissingCompounds), "COMPOUND B") > 0, 0, CurrentSignal.PeakOrGroupByName("Compound B").Compound_Concentration)



          Then the final step would be to update the CC that you are using to perform your sum so that it uses the CompoundA and CompoundB CCs as opposed to pulling the compound concentrations directly from the data file. Below is the CC I used for this purpose:


          (0.7*CompoundA) + CompoundB


          Below are the results generated by the custom calculations for a data file where Compound A is missing:



          Below is a screenshot of Custom Calculations in the ccf I used to generate the above results (hopefully you can zoom in enough to see the formulas):


          Hopefully this helps.

          1 person found this helpful