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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
agsearle
Creator
Creator

Multiple Expression

I'm trying to enter more than one IF statement into a calulated dimension within a chart straight table.

I have a field with lots of dates going back a number of years, and I want to place them into ranges (up to 1 Month old, 2 months old, 3 months old etc etc)

When I enter this it correctly finds the dates under 1 month.
IF(Due_Date>TODAY()-30, '1 Month')

However, when I enter another IF statement in the same expression like this, nothing is shown.
IF(Due_Date>TODAY()-30, '1 Month')
OR IF(Due_Date>TODAY()-60 AND Due_Date<TODAY()-31,'2 Months')

What am I doing wrong?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Andrew,

I use to avoid that happening doing nested ifs, although performance may be severly affected. Something like (untested)

IF(Due_Date>TODAY()-30, '1 Month', IF(Due_Date>TODAY()-60 AND Due_Date<TODAY()-31,'2 Months'))
and so. Hope this helps.

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hello Andrew,

I use to avoid that happening doing nested ifs, although performance may be severly affected. Something like (untested)

IF(Due_Date>TODAY()-30, '1 Month', IF(Due_Date>TODAY()-60 AND Due_Date<TODAY()-31,'2 Months'))
and so. Hope this helps.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Andrew,

let me emphasize the importance of Miguel's comment.

IF statements, and especially nested IF statements, severely damage performance. Even if your application is very small, as a matter of learning and following best practices, move your IF question from the run-time back to the load time and create those additional buckets back in the script (typically it's done within the "Calendar" table, if you have one...)

cheers,

agsearle
Creator
Creator
Author

Thanks for your advice guys, I've used Miguel's suggestion, and used it in the load script instead.

It works well! Big Smile