Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
43918084
Creator II
Creator II

Create Vairance column in Pivot Table

I have created a pivot table with 2 periods and want to add Variance column to show difference between previous period vs current period.

I have created a set analysis formula like below, but I do not get the correct result.

=(Sum({<[ACCTG DATE (P0045)]={$(=max([ACCTG DATE (P0045)]))}>}[FUNCTIONAL AMT(YTD)])
- Sum({<[ACCTG DATE (P0045)]={$(=min([ACCTG DATE (P0045)]))}>}[FUNCTIONAL AMT(YTD)]))

The result I want is

 FunctionFunctionVar
ACCTG DATE (P0045)201912312020013120200131 vs 20191231
Status20,191,23120,200,1318,900
Totals(19,510,795)(19,304,099)206,696
Exist(19,510,795)(19,304,099)206,696

 

But I get an incorrect result like below.  Hope I can get some guidance

 FunctionFunctionVarVar
ACCTG DATE (P0045)20191231202001312019123120200131
Status20,191,23120,200,13120,191,23120,200,131
Exist(19,510,795)(19,304,099)19,510,795(19,304,099)

 

10 Replies
tresesco
MVP
MVP

Have you tried like: 

Var = Column(1) - Column(2)

?

43918084
Creator II
Creator II
Author

Thank you very much.  When I use your suggested formula, the result becomes "-"

 FunctionFunctionVarVar
ACCTG DATE (P0045)20191231202001312019123120200131
Status20,191,23120,200,13120,191,23120,200,131
Exist(19,510,795)(19,304,099)--
tresesco
MVP
MVP

Could you share a sample app to check?

43918084
Creator II
Creator II
Author

Sure thank you very much for your immediate help. Sorry I don't know how to attach the file here.  Hope you would not mind to advice.

tresesco
MVP
MVP

Click on the clip symbol on the left bottom corner of edit window.

43918084
Creator II
Creator II
Author

 

I am really sorry for my inexperience. There is no Clip symbol in my screen.

tresesco
MVP
MVP

This?

Capture.PNG

43918084
Creator II
Creator II
Author

Thanks a lot for your patience.  Somehow the Clip icon is not visible in my screen.  I have to put my mouse around to find it.  I have attached the qvf file here.  The Pivot table is under YTD Variance (Based on SAL)

Thank you very much again

tresesco
MVP
MVP

Since you have multiple members (dates) in column - you would get multiple outputs for an expression (and NOT one -unlike you want). To get one variance column, you have to modify your script I believe.