Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
StacyCui
Creator
Creator

show sum OR which is less than 0

Hi, I want to calculate the sum value whose  the difference value is less than 0 in two year.  Here comes my function, but it shows -, if I changed into >0, it will show the value, what's wrong with it?

if(sum(aggr($(V_CY Till_OR)-$(V_PY_Till_OR),CNOC))<0,sum(aggr(($(V_CY Till_OR)-$(V_PY_Till_OR)),CNOC)))

StacyCui_0-1669345997783.png

 

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Try below

=sum( aggr(

 if(  $(V_PY_Till_OR)> $(V_CY Till_OR),$(V_CY Till_OR)-$(V_PY_Till_OR) )

,CNOC))

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
vinieme12
Champion III
Champion III

can you post a screenshot from the expression editor?

also what are variables  V_CY Till_OR  and  V_PY_Till_OR

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
StacyCui
Creator
Creator
Author

Pls take a look. Thank you so much

StacyCui_0-1669347001052.pngStacyCui_1-1669347030196.pngStacyCui_2-1669347050583.png

 

StacyCui
Creator
Creator
Author

if I changed into >0, It will work. like below

StacyCui_3-1669347162481.png

 

StacyCui
Creator
Creator
Author

If I select a customer whose difference value is  less than 0, this function will show the value, if I don't select , it will show -

if(sum(aggr($(V_CY Till_OR)-$(V_PY_Till_OR),CNOC))<0,sum(aggr(($(V_CY Till_OR)-$(V_PY_Till_OR)),CNOC)))

vinieme12
Champion III
Champion III

Try below

=sum( aggr(

 if(  $(V_PY_Till_OR)> $(V_CY Till_OR),$(V_CY Till_OR)-$(V_PY_Till_OR) )

,CNOC))

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
StacyCui
Creator
Creator
Author

wow, It works. But  What's the reason?