Expression in Report Builder for Result interpretation using CalculatedConcentration, FinalConcentration, or SampleAmount

This is the last portion of this template I need to customize and need help with, I promise!  

I have a column for the final concentration which was from the shipping template previously identified.  I like the term “calculated concentration” better than “final concentration” as a Field Caption, but we aren’t diluting the samples or doing any other multipliers, so “final concentration” is being used as the term in the Expression. 

This is the existing column and the Expression functions properly:

I need another column which will allow for the interpretation of that Final Concentration since this is a semi-quantitative assay.  I’m calling that column “Result.” 

The assay is a single point calibration of 0.050 and includes the origin.  In MS Quant for this method, Outliers are flagged outside the calibration range for being less than 0.050 and greater than 0.050.   It seems like I could easily play off of this for the logic of the Expression needed.   I just want anything less than 0.050 to result as “< 1%” and be light gray and anything above 0.050 to result as “> 1%” and be green in this added Result column. 

MS Quant specifies “Calculated Concentration” in flagging the Outliers.    

Under “Calibration Range” in the Schema, the Outlier metric is put in terms of “Calculated Concentration” and not “Final Concentration.”  The Schema specifies that “This outlier is always activated unless the batch uses the standard addition quantitation” so there wasn’t anything to activate in the MS Quant method. 

Hopefully what I’m trying to get for this column will be obvious by the attempted Expression seen below.  I’ve tried both “CalculatedConcentration” and “FinalConcentration” but neither has worked. 


 I get this same error for attempts using “CalculatedConcentration” language and “FinalConcentration” language in the Expression.  I’m sure there is an issue between these since I'm technically using "Final Concentration" and there are no Outliers to designate for it.  If there is no easy fix for this, should I consider SampleAmountLimitHigh, SampleAmountLimitLow, and OutlierSampleAmountOutOfLimits instead to try to get what I need?

  • Hi  ,

    There are a few things going on here so let me try to explain.

    The final line in most of the shipping expressions is called a ternary conditional operator. This functions the same way as the more conventional if...else statements, but the format is a little different.

    Normally you would use expressions similar to how the cell colors are being set (these examples are pseudocode and not Python unless otherwise noted)

    if a then

    While this can be used for conditional formatting of the cell itself, using this type of if statement to actual print either x or y in a report cell won't work. From what I have found only a statement that starts with no indentation will print in a cell.

    One way around this is to use the ternary operator which takes the form

    x if a else y

    This is how most of the shipping templates evaluate conditionals and generate output. Generally, the ternary operator does not allow for any other conditions. The following cannot be easily written as a ternary.

    if a then
    else if b then

    If you need this kind of logic, then what you can do is set up your expression in the general form of

    if a then
    else if b then

    This will print the value of the variable result in the report. No actual print command is needed.

    You will need to decide whether to evaluate the final or calculated concentration in the report or use one of the outliers. If you choose to evaluate the concentration in the report, you will need to edit the report if your method limit changes. If you can use an outlier, changes to the quant method will automatically be reflected in the report.

    If you check the outlier flag, you would evaluate that as either being "Low" or "High". If you are checking the concentration directly you would evaluate it against the numeric limit.

    An expression like this (actual Python code) should work to check directly against the Calculated or FinalConcentration. It will print "< 1%" if there is no result or if the result is less than 0.050. If the result is 0.050 or higher then it will print "> 1%".

    "< 1%" if BoundItems["TargetPeak"] is None or BoundItems["TargetPeak"].IsFinalConcentrationNull() or BoundItems["TargetPeak"].FinalConcentration < 0.050 else "> 1%"

    The unexpected token error, as mentioned in this post, is a syntax error. If fixing the ternary operator does not resolve this, then you will have to try the suggestions in that post to isolate the issue.

Was this helpful?