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: 
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?

Labels (1)
1 Reply
marcus_sommer
MVP
MVP

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