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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
janus2021
Creator
Creator

If statment dont work as aspected.

Hi.
I enter the following terms for a line in a line chart: "=IF (Period > date(AddMonths(Today(), -13, 0), 'YYYYMM'), Period)"

I want to get out continuously for the last thirteen months. Unfortunately, all months in Period are returned. What am I doing wrong?

 

Regards

Jan

1 Solution

Accepted Solutions
GaryGiles
Specialist
Specialist

Is your Period field a date field or is it a numeric value of say, 202101?

The Date() function will return a date field.  The 'YYYYMM' is simply the display formatting, so if Period is a numeric field, you are comparing a numeric to a date field.

Try this:

=if(YearMonth > Year(AddMonths(Today(),-13))&Num(Month(AddMonths(Today(),-13)),'00'), YearMonth)

If that returns the desired results, the Period data type is most likely the issue.

 

View solution in original post

2 Replies
GaryGiles
Specialist
Specialist

Is your Period field a date field or is it a numeric value of say, 202101?

The Date() function will return a date field.  The 'YYYYMM' is simply the display formatting, so if Period is a numeric field, you are comparing a numeric to a date field.

Try this:

=if(YearMonth > Year(AddMonths(Today(),-13))&Num(Month(AddMonths(Today(),-13)),'00'), YearMonth)

If that returns the desired results, the Period data type is most likely the issue.

 

janus2021
Creator
Creator
Author

yes, Period is a numeric field.

your solution gave the desired result, thank you very much for the help.