AnsweredAssumed Answered

Custom calculator not working with empty or NULL value

Question asked by h2onet on Jul 3, 2020
Latest reply on Jul 7, 2020 by martin.adams

I am using the Custom Calculator and have a simple calculation, but when one of the values passed into the equation is empty, nothing is displayed.

 

In the specific screenshot example below, There is a value for "THC_Percent", but "THCA_Percent" is NULL or blank.  How do I get this to work with a NULL value?

 

I tried the following with no luck:

   -IIf(THCA_Percent = "",THC_Percent,(THCA_Percent*.877)+THC_Percent) 
   -If(isNothing(THCA_Percent),THC_Percent,(THCA_Percent*.877)+THC_Percent)

 

I then thought that since the first value I need is the compound amount for THCA that I would try checking the value "THCA Amount" as a null value and give it a zero value, so I tried (with two versions - the zero value enclosed by double quotes, and not):
   -IIf((CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount)="","0",(CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount))

   -IIf((CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount)="",0,(CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount))

   -IIf(isNothing((CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount)),"0",(CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount))

   -IIf(isNothing((CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount)),0,(CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount))

 

And then, just for giggles, I tried using a value other than zero:
   -IIf(isNothing((CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount)),"foo",(CurrentInjection.AllPeaksAndGroupsByName("THCA").First().Compound_Amount))

 

Outcomes