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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jenmclean
Contributor III
Contributor III

Subtract two fields based on year

if(PROD_StoreID='34',
(
if(PROD_Year='2014',PROD_CPH_Actual))-(if(PROD_Year='2015',PROD_CPH_Actual)))

By Store, I need to subtract PROD_CPH_Actual from 2014 and 2015. What is the best way to write this?

1 Reply
marcus_sommer

You could use set analysis for this - in this case changed to flexible years depending from the selections but you could replace it with fixed values like the StoreID:

sum({< PROD_StoreID = {34}, PROD_Year = {"$(=max(PROD_Year) -1)"}>} PROD_CPH_Actual) -

sum({< PROD_StoreID = {34}, PROD_Year = {"$(=max(PROD_Year))"}>} PROD_CPH_Actual)

- Marcus