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: 
Not applicable

Prior year calculation problem

Hi guys. Currently I have a actual sales calculation like this

=sum(SalesAmount)-sum(SalesAmount*(DiscPrcnt/100))-sum(CreditAmount)+sum(CreditAmount*(CNDiscPrcnt/100))



I want to compare prior year actual sales with current year actual sales. I got this formula in the forums:

num(sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} SalesAmount), '#,##0;(#,##0)')

I do not know how to place the actual sales calculation as mentioned on top into this formula. As you will see that this formula only sum(SalesAmount), but I need to add the whole calc as shown on top.

Could someone please assist me. It looks like some simple answer.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Try like this

=num(

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} SalesAmount)-

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} SalesAmount*(DiscPrcnt/100))-

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} CreditAmount)+

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} CreditAmount*(CNDiscPrcnt/100))

, '#,##0;(#,##0)')



View solution in original post

2 Replies
Anonymous
Not applicable
Author

Try like this

=num(

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} SalesAmount)-

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} SalesAmount*(DiscPrcnt/100))-

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} CreditAmount)+

sum({$<Year = {$(=only(Year) - 1)}, Month = {"<=$(=max(Month))"}>} CreditAmount*(CNDiscPrcnt/100))

, '#,##0;(#,##0)')



Not applicable
Author

Thank you. This works perfectly.