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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
ruma_barman
Creator
Creator

Set Analysis in Pivot Table

There is a dimension named Revenue and a dimension named Month Name from master calender and I have to show

in a pivot table Month Name as the dimension and expression is sum of revenue for the corresponding month minus sum of revenue of the previous month.

Example: For Jan 2017 ,it should show sum of revenue of Jan 2017 minus sum of revenue of Dec 2016 in the table.

Refer screenshot.

Labels (1)
20 Replies
Anil_Babu_Samineni
MVP
MVP

May be this?

Sum({<[Month Name] = {'$(=Max([Month Name]))'}>}revenue)-Sum({<[Month Name] = {'$(=AddMonths(Max([Month Name]),-1))'}>}revenue)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ruma_barman
Creator
Creator
Author

Hi Anil,

Thanks for you reply,but it didn't work that way.

Thanks,

Ruma

Anil_Babu_Samineni
MVP
MVP

Why, May be some other work would be needed. Can you provide Sample

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tresB
Champion III
Champion III

Try like:

RangeSum( Sum(Revenues), - Before(Sum(Revenues)))

ruma_barman
Creator
Creator
Author

Hi Tresesco,

In this case when two months are selected ,say Dec'16 and Mar'17,Mar'17 will show revenue of Mar'17 - revenue of Dec'16 but actually it should show revenue of Mar'17 - revenue of Feb'17.

tresB
Champion III
Champion III

Then, you might have to use set analysis in combination with aggr(). Try to share your sample qvw for specific help.

ruma_barman
Creator
Creator
Author

Hi Anil,

One sample data is attached.

ruma_barman
Creator
Creator
Author

Hi Tresesco,

One sample data attached.

tresB
Champion III
Champion III

Try expression like:

Aggr(

          Rangesum(Sum({<[Month Name]>}Revenue),-above((Sum({<[Month Name]>}Revenue))))

,[Month Name])