In this article:
Algorithm Engine™: Return Text Value
When creating fields, you may want to create a field that allows you to generate a text value based on a field that has a number value.
- Create a field that has a Value Type of "Calculated".
- Locate the "Calculated Configuration" section of the menu.
- In the Number Expression box, create a logical statement in the following format:
- CONDITION ? PASS_VALUE : FAIL_VALUE :
- The condition will be the constraints of the number value that you are referencing (measurements.field > 10).
- The pass value will be a number that you would like to associate with the text value that will be displayed (1 = “Pass”)
- The fail value is what the value will be if the condition is not met. It is recommended that if you don't want anything displayed if it fails the condition, that you use "null" (0 = “Fail”).
- The condition will be the constraints of the number value that you are referencing (measurements.field > 10).
- CONDITION ? PASS_VALUE : FAIL_VALUE :
- In the box directly under that one titled, "String Expression", you will need to put in another logical statement with a condition.
- This time, you will set the condition as "number_value ==". "number_value" will reference the number generated in the Number Expression box. You can then place the text string you would like in the pass_value place surrounded by quotes. Again, if you do not want anything displayed for a value that fails the condition, it is recommended that you use null.
- This time, you will set the condition as "number_value ==". "number_value" will reference the number generated in the Number Expression box. You can then place the text string you would like in the pass_value place surrounded by quotes. Again, if you do not want anything displayed for a value that fails the condition, it is recommended that you use null.
- See the following example as the reference. It states, if the field with the expression name, "body_fat_percent" is greater than 10, then it will display "CAUTION".
- Number Configuration: measurements.body_fat_percent > 10 ? 1 : 0
- String Expression: number_value == 1 ? "CAUTION" : null
- Number Configuration: measurements.body_fat_percent > 10 ? 1 : 0
Comments
0 comments
Please sign in to leave a comment.