Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

expression for summation of previous 3 months columns for selected month

HI Sir,

I am developing Purchase analysis report in that I want to write expression for Consumption qty for last 3 months sum from the selected

month. for that column i have data for 12 months in terms of  columns in a table MVER from SAP database. it includes 12 columns for 12 months how to write the expression for previous 3 months qty from selected month.

Ex : I have selected Aug month then I want summation of qty for May , June , July data from that table columns

12 Replies
tresesco
MVP
MVP

Try something like:

Sum({<Month={">$(=(Max(Month)-3))"}>}Amount)

With field data format right, this should work.

Not applicable
Author

HI Sir,

But I have columns such as GSV01,GSV02,GSV03,...,GSV12 and if GSV01 is for Jan , GSV02 as feb,.....GSV12 as dec and when I select Aug then i want sum(GSV05+ GSV06+GSV07). so how i will write expression for that.

tresesco
MVP
MVP

Please share your sample app.

Not applicable
Author

HI Sir,

Please find an attachment. In that I have selected 2012 JUn And particular Material Code. And I want sum of GVS03,GVS04,GVS05

AS i SELECT Jun so sum(Apr + May + June) columns. So how to write expression for that month and it will be dynamic.

yevgeniy
Creator
Creator

Hi,

In you calendar, set month jan as 1, Feb as 2 .......

Set column as YearMonth: 201211,201212,20131,20132........

And Tresesco say:

Sum({<YearMonth={">$(=(Max(YearMonth)-4))<$(=(Max(YearMonth)))"}>}Amount)

Not applicable
Author

HI Sir,

I want the sum of data of that column not amount. Sum(GSV01+GSV02+GSV03)

tresesco
MVP
MVP

Hello,

PFA, i have tried to replicate your issue and solution accordingly. Hope this would help you.

tresesco
MVP
MVP

Hi Pankaj,

Did you check if the attached solution was helpful?

Not applicable
Author

HI Sir,

Thankx for sample app it's working but if I selected suppose 2013 jan then I want sum of oct , nov , dec for 2012

it menas i want expression including year filter also for that also i have year field in DB but how I link this field with calender year . so how to write expression including year filter also.