Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum of previous 12 months

Hi,

I need to calculate the sum of the previous 12 months of the selection. For example, if I choose 2013 as Year(Filter), I want to calculate the sum from Feb 2012 - Jan 2013 or If I choose 2013 as Year (filter) and March as Month(Filter, I want to calculate the sum from Apr 2012 - March 2013.

I am using this formula but it is giving me the wrong answer.

(Rangesum(Above((sum({$<Year = {$(=Only(Year))}>} Sales)),0,12)))

How can I solve this?

Thanks in Advance

1 Solution

Accepted Solutions
Siva_Sankar
Master II
Master II

Maria,

Try with this:

sum({< PeriodFilter=, [Period ID]={">=$(=max([Period ID])-12)<=$(=max([Period ID]))"}>} Sales)

Where PeriodFilter is the filter that use in your report

Regards.

siva

View solution in original post

3 Replies
Siva_Sankar
Master II
Master II

Maria,

Try with this:

sum({< PeriodFilter=, [Period ID]={">=$(=max([Period ID])-12)<=$(=max([Period ID]))"}>} Sales)

Where PeriodFilter is the filter that use in your report

Regards.

siva

AbhijitBansode
Specialist
Specialist

From explanation, I understand that, you need sales for current month plus previous eleven months always.

I would recommend to assign unique value to each month (ID) in th script using Autonumber function and use set expression like below:

Sum ({< ID= {">= $(=Max(ID)-11) <= $(=Max(ID))"}>} Sales)