Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if...elseif... in calculated dimensions

I need to reflect in a column graph (stacked) how many helpdesk jobs are completed on time, completed late and still outstanding. So far through a calculated dimension I've managed to show number of jobs completed late and on time by using the following if statement:

=if (FINISH_DATE >> DUE_DATE, 'Late','On time')

When I used if...elseif...else...end if I couldn't make it work, it tells me I've got garbage expression. What can I do if I have more than two options to display?

Many thanks in advance

1 Solution

Accepted Solutions
Gysbert_Wassenaar

You can nest if statements:

if( condition1,

    result1,

    if( condition2,

        result2,

        result3)

  )


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar

You can nest if statements:

if( condition1,

    result1,

    if( condition2,

        result2,

        result3)

  )


talk is cheap, supply exceeds demand
Not applicable
Author

genius! thank you so much!

Not applicable
Author

Hi,

I have a similar problem and didn't want to start a new discussion just for it. This is what I have and it seems fine till the second IF and after that apparently it's 'garbage'. It is an expression in a straight table:

if(

     YEAR_END_NUMBER = 12

AND

     month(CAL_DATE) > 3

AND

     month(CAL_DATE) < 7 ,

sum(IM*GB)),

if (

     YEAR_END_NUMBER <> 12

AND

     month(CAL_DATE) > YEAR_END_NUMBER + 3

AND

     month(CAL_DATE) < YEAR_END_NUMBER + 7,

sum(IM*GB),

'no data')

Gysbert_Wassenaar

Try it like this:

if(

     (YEAR_END_NUMBER = 12

  AND

     month(CAL_DATE) > 3

  AND

     month(CAL_DATE) < 7 )

OR          

(     YEAR_END_NUMBER <> 12

  AND

     month(CAL_DATE) > YEAR_END_NUMBER + 3

  AND

     month(CAL_DATE) < YEAR_END_NUMBER + 7

),

sum(IM*GB),

'no data')


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you! This worked fine

By the way, why does it not work for calculated dimension? Is it for calculated expressions only?