Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Mathematical.Num() in Expression Builder

I am trying to format a string into a specific format only if it is numeric.
I am using the following expression in the tmap.
Mathematical.NUM(row.number) ? String.format("%010d", Double.parseDouble(row.number)) : row.number 
I am getting a compilation error: Type Mismatch: Cannot convert int to boolean.
Labels (2)
2 Replies
Anonymous
Not applicable
Author

Hi,
Mathematical.NUM(row.number) ? String.format("%010d", Double.parseDouble(row.number)) : row.number

Could you please elaborate your case with an example with input and expected output values? 
Would you mind posting your tMap editor screenshot into forum?
Best regards
Sabrina
Anonymous
Not applicable
Author

You are getting that error since that 1-line if-else statement needs a BOOLEAN expression at the left side, but Mathematical.NUM returns an INTEGER value 1 if the parameter passed is a numeric data type, or 0 if otherwise. So you have to add a bit of code to your decision statement, such that it checks if the returned value is equal to 1 or not (added code in red bold):
Mathematical.NUM(row.number) == 1? String.format("%010d", Double.parseDouble(row.number)) : row.number