Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
rickarora12
Contributor
Contributor

Is there a user friendly way to do this if then logic??

set V_Start=201907;
set V_Start_Month = 'if( V_Start=201907, 201905 , if( V_Start=201908, 201906 , if(V_Start=201909, 201905, 201904)))';

 

Hi All,

I have this code above where if there is a specific time period YYYYMM(201907) I want to display another time period e.g. 201905.

 

The code above I have created works fine, my concern is that the developer or analyst viewing this might have some trouble following.  Can I use a if then else script to do the same as above? I have tried but the code starts erroring out with set and let logic wanting quotes etc..

 

Thanks in Advance!!

Rick

1 Solution

Accepted Solutions
vikramv
Creator III
Creator III

try like this..

set V_Start_Month = 'IF ( PICK(Match(V_Start,201907,201908,201909)+1,201904,201905,201906,201905)';

Thanks.

Vikky

View solution in original post

3 Replies
vikramv
Creator III
Creator III

try like this..

set V_Start_Month = 'IF ( PICK(Match(V_Start,201907,201908,201909)+1,201904,201905,201906,201905)';

Thanks.

Vikky

rickarora12
Contributor
Contributor
Author

Thanks for the quick reply, is the +1 just pick the next number

For my purpose I used your solution with a minor change

set V_Start_Month = PICK(Match(V_Start,201907,201908,201909,201910),201906,201907,201908,201909);

 

Very cool, simple and elegant

Thanks
Rick

vikramv
Creator III
Creator III

Welcome !

+1 is like similar to else condition of if-else in SQL.

Hope that helps.

Thanks.

Vikky