Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Yean
Contributor II
Contributor II

If else statement with Let variable

Let FirstHalfDate = Date(MonthStart(Addmonths('2022-07-01',-6)),'MM');

Let SecondHalfDate = Date(MonthStart(Addmonths('2022-01-01',-6)),'MM');
 
Let CutOffDate = IF MONTH(TODAY()) <= 0
                 THEN '$(FirstHalfDate)';
                 ELSE IF '$(SecondHalfDate)';
                 END IF
 
Hello, I want to use if else statement with the Let variable, above is what I typed but Qlik keeps on giving me error at the Let CutOffDate variable, anyone know where did I do wrong? 
 
Thanks in advance.
Labels (2)
1 Solution

Accepted Solutions
sidhiq91
Specialist II
Specialist II

@Yean  Could you please try the below expression. I got the desired output.

Let FirstHalfDate = Date(MonthStart(Addmonths('2022-07-01',-6)),'MM');

Let SecondHalfDate = Date(MonthStart(Addmonths('2022-01-01',-6)),'MM');

Let CutoffDate =if(Month(Today())<=06,'$(FirstHalfDate)','$(SecondHalfDate)');

If this resolves your issue, please like and accept it as a solution.

View solution in original post

2 Replies
sidhiq91
Specialist II
Specialist II

@Yean  Could you please try the below expression. I got the desired output.

Let FirstHalfDate = Date(MonthStart(Addmonths('2022-07-01',-6)),'MM');

Let SecondHalfDate = Date(MonthStart(Addmonths('2022-01-01',-6)),'MM');

Let CutoffDate =if(Month(Today())<=06,'$(FirstHalfDate)','$(SecondHalfDate)');

If this resolves your issue, please like and accept it as a solution.

Yean
Contributor II
Contributor II
Author

Thank you so much !!!!

I guess I've confused with SQL if else statement ><