Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

How to write nested if conditions or case statements to suit the following requirement

Hi All,

Please help me with the code given below.

IF(VIDEO_TYPE='DVR',

       IF(TIMESHIFT_ID> 9,'DVR After 7 Days','DVR Till 7 Days'),

            IF(VIDEO_TYPE='OTT/VOD',

                 IF(STREAMING_SOURCE='VOD',

                      IF((TIMESHIFT_ID> 5,'VOD Till 3 Days','VOD After 3 Days'),'OTT',

VIDEO_TYPE)))) AS VIDEO_PLATFORM_W_VOD,

There is something wrong in this code, iam using this in the load statement in qliksense to get the dimension for a specific use.

The purpose of this is to include DVR as a first condition and in the inner loop TIMESHIFT_ID>9 if success display1 or display2

First condition checks for DVR, 3rd again checks for VIDEO_TYPE = OTT/VOD. The above statement is giving an error while loading the data in qliksense. Please help me its urgent

Thanks

P.Ravikiran

09590574999

1 Solution

Accepted Solutions
MVP
MVP

Re: How to write nested if conditions or case statements to suit the following requirement

Give this a try:

If(VIDEO_TYPE='DVR', If(TIMESHIFT_ID > 9, 'DVR After 7 Days', 'DVR Till 7 Days'),

If(VIDEO_TYPE='OTT/VOD', If(STREAMING_SOURCE='VOD', If(TIMESHIFT_ID > 5,'VOD Till 3 Days', 'VOD After 3 Days') ,'OTT'), VIDEO_TYPE)) AS VIDEO_PLATFORM_W_VOD

6 Replies

Re: How to write nested if conditions or case statements to suit the following requirement

Try this:

IF(VIDEO_TYPE='DVR',

       IF(TIMESHIFT_ID> 9,'DVR After 7 Days','DVR Till 7 Days'),

            IF(VIDEO_TYPE='OTT/VOD',

                 IF(STREAMING_SOURCE='VOD',

                      IF((TIMESHIFT_ID> 5,'VOD Till 3 Days','VOD After 3 Days'),'OTT',

VIDEO_TYPE)) AS VIDEO_PLATFORM_W_VOD,

Not applicable

Re: How to write nested if conditions or case statements to suit the following requirement

In Line 5, there seems to be no if condition to test for TIMESHIFT_ID.

I think it should be a Single paranthesis:

IF(TIMESHIFT_ID> 5,'VOD Till 3 Days','VOD After 3 Days'),'OTT',

Not applicable

Re: How to write nested if conditions or case statements to suit the following requirement

Hi Thanks for the replies,

I have tried this but still it does not work. Any alternate solution for this in qliksense load script.

IF(VIDEO_VIEW_TYPE='DVR',

       IF(TIMESHIFT_INDICATOR_ID> 9,'DVR After 7 Days','DVR Till 7 Days'),

            IF(VIDEO_VIEW_TYPE='OTT/VOD',

                 IF(STREAMING_SOURCE='VOD',

                      IF(TIMESHIFT_INDICATOR_ID> 5,'VOD Till 3 Days','VOD After 3 Days'),'OTT',

VIDEO_VIEW_TYPE))) AS VIDEO_VIEW_PLATFORM_W_VOD,

Thanks in Advance

MVP
MVP

Re: How to write nested if conditions or case statements to suit the following requirement

Give this a try:

If(VIDEO_TYPE='DVR', If(TIMESHIFT_ID > 9, 'DVR After 7 Days', 'DVR Till 7 Days'),

If(VIDEO_TYPE='OTT/VOD', If(STREAMING_SOURCE='VOD', If(TIMESHIFT_ID > 5,'VOD Till 3 Days', 'VOD After 3 Days') ,'OTT'), VIDEO_TYPE)) AS VIDEO_PLATFORM_W_VOD

Not applicable

Re: How to write nested if conditions or case statements to suit the following requirement

Thanks Sunny,

The code given by you has executed correctly.

MVP
MVP

Re: How to write nested if conditions or case statements to suit the following requirement

Awesome

I am glad it worked.

Best,

Sunny