Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
jonathanrichey
New Contributor II

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
Esteemed Contributor II

Re: Set Analysis Syntax with greater than and less nested

Your logic is correct; but instead, use AddYearS not addyear
7 Replies
avkeep01
Valued Contributor

Re: Set Analysis Syntax with greater than and less nested

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
New Contributor II

Re: Set Analysis Syntax with greater than and less nested

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).

 

Re: Set Analysis Syntax with greater than and less nested

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
Esteemed Contributor II

Re: Set Analysis Syntax with greater than and less nested

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

Re: Set Analysis Syntax with greater than and less nested

Or this

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

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

Re: Set Analysis Syntax with greater than and less nested

Good catch 🙂

jonathanrichey
New Contributor II

Re: Set Analysis Syntax with greater than and less nested

This works as well.Thanks for the responses!!