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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
LEGION
Contributor II
Contributor II

Perform a calculation for last 12 months

Hello, I am struggling with a calculation. I am calculating NETT sales using the following formula: 

(((Sum({<TCODE={'IN'}>} AMOUNT))-(Sum({<TCODE={'CN'}>} AMOUNT)))-((Sum({<TCODE={'IN'}>} PROFIT))-(Sum({<TCODE={'CN'}>} PROFIT))))

This works just fine, but I only want to perform this calculation on data that fall in the last 12 months, my date field is [TXDATE].

Unless this is not possible and someone could please point me in the correct direction.

 

Thank you in advance 🙂

Labels (1)
1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

change to

(((Sum({<TCODE={'IN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} AMOUNT))-(Sum({<TCODE={'CN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} AMOUNT)))-((Sum({<TCODE={'IN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} PROFIT))-(Sum({<TCODE={'CN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} PROFIT))))

 

Regards

View solution in original post

2 Replies
martinpohl
Partner - Master
Partner - Master

change to

(((Sum({<TCODE={'IN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} AMOUNT))-(Sum({<TCODE={'CN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} AMOUNT)))-((Sum({<TCODE={'IN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} PROFIT))-(Sum({<TCODE={'CN'}, TXDATE={">=$(=date(addmonths(today(),-12)))"}>} PROFIT))))

 

Regards

LEGION
Contributor II
Contributor II
Author

Thank you so much, this worked perfectly 🙂