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: 
jonathanrichey
Contributor III
Contributor III

Set Analysis Syntax with greater than and less nested

I am working on a set analysis expression and it seams I have the logic reversed. I would like my chart to show data only within the last two years. 

Where should the greater than or less than operators be used within the equation?

 

count({<MonthYear ={">=$(=Date(AddYear(MonthYear, -2), 'MMM YYYY'))"}>}ID)

Labels (2)
1 Solution

Accepted Solutions
OmarBenSalem

Your logic is correct; but instead, use AddYearS not addyear

View solution in original post

7 Replies
avkeep01
Partner - Specialist
Partner - Specialist

Hi @jonathanrichey

The ' aren't working. You could use this. You only need to make sure that the field Date has the same format as the default date settings at the beginning of your script. 

 

=count({<Date ={">=$(=Date(AddYear(MonthYear, -2)))"}>}ID)

 

jonathanrichey
Contributor III
Contributor III
Author

Thanks for the quick response @avkeep01 !

 

My date is set to=

SET DateFormat='M/D/YYYY';

Currently I have MonthYear as my dimension. I am not sure what is calculating when using the updated expression (see MonthYear.png. 

If I change my dimension to Date vs MonthYear my data displays only November and December 2015 (Date.png).

 

sunny_talwar

May be you need this

Count({<MonthYear = {">=$(=Date(AddYears(Max(MonthYear), -2), 'MMM YYYY'))"}>} ID)

UPDATE: fixed the function name to AddYears based on Omar's response below 

OmarBenSalem

Your logic is correct; but instead, use AddYearS not addyear
sunny_talwar

Or this

Count({<MonthYear = {">=$(=Date(AddYears(Today(), -2), 'MMM YYYY'))"}>} ID)

UPDATE: fixed the function name to AddYears based on Omar's response below  

sunny_talwar

Good catch 🙂

jonathanrichey
Contributor III
Contributor III
Author

This works as well.Thanks for the responses!!