Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
juriengroot
Contributor III
Contributor III

Set analysis, 12 months prior with p() function

Hi,

I have a table with the following column / measure:

Sum({$<[Order Ship MonthID]= p(MonthID), [Order Create MonthID]= p(MonthID)   >}Orders)

That is working perfect for what I want. Now I want to have the values from 12 months prior next to it.

I tried something like:

Sum({$<[Order Ship MonthID]= p($(MonthID)-12), [Order Create MonthID]= p($(MonthID)-12)  >}Orders)

Is it possible to have a calculation for all values in p()? What would be the syntax?


Thanks in advance!

3 Replies
sunny_talwar

May be create a new field in the script

LOAD MonthID,

          AddMonths(MonthID, -12) as PrevMonthID

and then try this

Sum({$<[Order Ship MonthID]= p(PrevMonthID), [Order Create MonthID]= p(PrevMonthID)>}Orders)

juriengroot
Contributor III
Contributor III
Author

Hi Sunny, Good idea, I tried it but it plots the values not on the same line in that case. It just brings in the period of 12 months prior. I guess this makes sense, but I'd like to Jan 2017 with the values of Jan 2016 next to it. Any idea?

orders.PNG

I would like to keep the months continuous and not discrete!

sunny_talwar

There is few ways you can handle this

1) Use The As-Of Table‌ or

2) Use Missing Manual - Above() and Below()