Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
bhavvibudagam
Creator II
Creator II

Last 12 months restriction

Hi Experts,

Can any one please help me on below requirement.

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.

How to get this. Please help me on it. Please find the attached Document.

201812.png

Thanks in advance

1 Solution

Accepted Solutions
OmarBenSalem

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

change ur expression as follow:

=Sum({<YearMonth={">=$(=date(addMonths(Max(YearMonth),-12),'YYYY/MM')) <$(=Max(YearMonth))"}>}Sales)

result:

Capture.PNG

Capture.PNG

see the attached app:

View solution in original post

3 Replies
OmarBenSalem

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

change ur expression as follow:

=Sum({<YearMonth={">=$(=date(addMonths(Max(YearMonth),-12),'YYYY/MM')) <$(=Max(YearMonth))"}>}Sales)

result:

Capture.PNG

Capture.PNG

see the attached app:

jonathandienst
Partner - Champion III
Partner - Champion III

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

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

No, that won't do it Jonathan;

in fact, in this case:

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

Capture.PNG