Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Terra
Contributor II
Contributor II

Subtract 2 columns that are filtered by date

New to Qlik. I need to subtract 2 columns in a pivot table. These 2 columns are filtered by a date and change based on the user input. I need to add a new column named 'Delta' that subtracts column 2 and 1 for all rows no matter what 2 dates are entered. 

Terra_0-1633668242337.png

Terra_1-1633668327499.png

Result:

Terra_3-1633669052643.png

.

.

.

 

1 Reply
rubenmarin

Hi, in date dimension you can check the option to show total, and using SecondaryDimensionality() to change the totals expression, and use set analysis to substract the amount of the min date to the max date.

In example if the current expresion is Sum(Amount), using totals it could be:

If(SecondaryDimensionality()=0
  ,Sum({<Date={'$(=Date(Max(Date)))'}>} Amount)-Sum({<Date={'$(=Date(Min(Date)))'}>} Amount)
  ,Sum(Amount)
)