Announcements
Product Release Webinar: Qlik Insider airing December 6! REGISTER TODAY!
cancel
Showing results for
Did you mean:  Creator II

## Issue when we add some values to the existing expression

The below expression does not work when I add "+21" to the Column(4), If we remove "+21" from the below expression it is working as expected. I tried using the actual expression and Label name instead of the Column(4) but no luck. Can someone please help on this.

if((Column(4)+21) < 22,'S1',
if(((Column(4)+21) >= 22 AND (Column(4)+21) < 84),'S2',
if(((Column(4)+21) >= 84 AND (Column(4)+21) < 273),'S3',
if(((Column(4)+21) >= 273 AND (Column(4)+21)<>'NA'),'S4','NA'
)
)
)
)

5 Replies  Specialist III

Hello Rikab,

Trust that you are doing well!

If possible, could you please share the application with sample data and desired output? This will help us to provide expected feedback.

Regards!

Rahul  MVP

What are the values with Column(4). Can you try with Num()

if(Num(Column(4))+21 < 22,'S1', if(Num(Column(4))+21 >= 22 and Num(Column(4))+21 < 84),'S2',

if(Num(Column(4))+21 >= 84 and Num(Column(4))+21 < 273),'S3', if(Num(Column(4))+21 >= 273 and Num(Column(4)) + 21 <>'NA'),'S4','NA'))))

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)  Partner - Champion III

I don't see any syntax errors, but there is one logical error

(Column(4)+21)<>'NA'

This will always be true as you are comparing a number with a string.

It would be easier to spot errors if you removed the unnecessary parentheses.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein  Partner - Champion III

Simply add a new expression to your chart, and put the following in the expression edit field:

=Column(4) + 21

Now observe what is happening with the expression results for different row values.

If this doesn't shed some light on what is producing unexpected behavior, then cut your expression into fout different parts and put each one of them in a different expression column. Because of being created as logical expressions, they should all produce either a 0 or a -1 value.  Partner - Champion III

I think this is what you are looking for:

if(Column(4) + 21 < 22, 'S1',

if(Column(4) + 21 < 84, 'S2',

if(Column(4) + 21 < 273, 'S3',

if(Column(4) + 21 >= 273 , 'S4', 'NA'

)

)

)

)

Or even simpler

if(Column(4) < 1, 'S1',

if(Column(4) < 63, 'S2',

if(Column(4) < 252, 'S3',

if(Column(4) >= 252 , 'S4', 'NA'

)

)

)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein Community Browser