How to have a IF Calculated field but returning text?

justin.leow asked on April 9, 2019


Would like to ask if it is possible for us to have a IF statement calculated field that returns text? Appreciate if you can advise the correct formula if possible. 

1 answer

Vera Didenko Flexmonster April 9, 2019

Hello, Justin,

Thank you for your question.

The calculated field can only return values of type number.

A way to achieve the desired output is to use the customizeCell property together with the calculated field:

1) Define the calculated field:

"measures": [
"uniqueName": "Weight Groups",
"formula": "if( sum(\"Operations Calculated Weight\") < 50, 0, 1)",
"caption": "Weight Groups"

2) Use customizeCell property to change the “0” and “1” in the column “Weight Groups” to the desired value:

customizeCell: function(cell, data) { 
if(data.measure != null && data.measure.uniqueName === "Weight Groups"){
if(cell.text == 0){
cell.text = ">=50kg"
}else if(cell.text == 1){
cell.text = "<50kg"

As a result, the cells of the “Weight Groups” column will show text as desired.

We have prepared a JSFiddle example for illustration.

Please let us know if this works for you and if you have further questions.

Best Regards,

Please login or Register to Submit Answer