Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
MVP & Luminary
MVP & Luminary

Re: if...elseif... in calculated dimensions

You can nest if statements:

if( condition1,

    result1,

    if( condition2,

        result2,

        result3)

  )


talk is cheap, supply exceeds demand
5 Replies
MVP & Luminary
MVP & Luminary

Re: if...elseif... in calculated dimensions

You can nest if statements:

if( condition1,

    result1,

    if( condition2,

        result2,

        result3)

  )


talk is cheap, supply exceeds demand
Not applicable

Re: if...elseif... in calculated dimensions

genius! thank you so much!

Not applicable

Re: if...elseif... in calculated dimensions

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')

MVP & Luminary
MVP & Luminary

Re: if...elseif... in calculated dimensions

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

Re: if...elseif... in calculated dimensions

Thank you! This worked fine

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