Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if then else

Goodmorning all,

I have a question.

dependent on a variable - a date - I would like to determine the quarter of this date. Something like:

if mid( vVariable , 4, 2 ) between 01 and 03 then 'Q1';

elsif mid( vVariable , 4, 2 ) between 04 and 06 then 'Q2';

elsif mid( vVariable , 4, 2 ) between 07 and 09 then 'Q3';

elsif mid( vVariable , 4, 2 ) between 10 and 12 then 'Q4';

end if;

I tried the above in several formats, but keep getting no result.

Does anybodt have a suggestion?

Thanks in advance.

1 Solution

Accepted Solutions
Sokkorn
Master
Master

Hi,

Try this: 'Q' & CEIL(MONTH([DateField])/3)    AS [Quarter]

Regards,

Sokkorn

View solution in original post

3 Replies
Not applicable
Author

IF (num(mid( vVariable , 4, 2 )) >= 1 AND num(mid( vVariable , 4, 2 )) <= 3, 'Q1',

  IF (num(mid( vVariable , 4, 2 )) >= 4 AND num(mid( vVariable , 4, 2 )) <= 6, 'Q2',

  IF (num(mid( vVariable , 4, 2 )) >= 7 AND num(mid( vVariable , 4, 2 )) <= 9, 'Q3',

  IF (num(mid( vVariable , 4, 2 )) >= 10 AND num(mid( vVariable , 4, 2 )) <= 12, 'Q4'))))

Sokkorn
Master
Master

Hi,

Try this: 'Q' & CEIL(MONTH([DateField])/3)    AS [Quarter]

Regards,

Sokkorn

Not applicable
Author

Brilliant - thanks