# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor II

## Last 12 months restriction

Hi Experts,

In the YearMonth Field I have records from 2017/01 to 2018/02.

Here I have to restrict last 12 months

Sum({<YearMonth={">=\$(=Max(YearMonth)-12) <\$(=Max(YearMonth))"}>}Sales)

with the above expression when I have selected 2018/01 then getting last 12 months from 2017/01 to 2017/12

but when i have selected 2018/02 then getting last 13 months from 2018/01 to 2017/01 but need to get 2018/01 to 2017/02.

1 Solution

Accepted Solutions
Esteemed Contributor

## Re: Last 12 months restriction

It's not taking into consideration the >=\$(=Max(YearMonth)-12) part

change ur expression as follow:

result:

see the attached app:

3 Replies
Esteemed Contributor

## Re: Last 12 months restriction

It's not taking into consideration the >=\$(=Max(YearMonth)-12) part

change ur expression as follow:

result:

see the attached app:

MVP

## Re: Last 12 months restriction

Sum({<YearMonth={">\$(=Max(YearMonth)-12) <\$(=Max(YearMonth))"}>}Sales)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Esteemed Contributor

## Re: Last 12 months restriction

No, that won't do it Jonathan;

in fact, in this case:

=date(Max(YearMonth)-12,'YYYY/MM') would go back by 12 days: