Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
An issue has been identified on Qlik Cloud hub, please visit our Status Update Page for details: GET THE LATEST
cancel
Showing results for 
Search instead for 
Did you mean: 
StacyCui
Contributor III
Contributor III

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
Contributor III
Contributor III
Author

Pls take a look. Thank you so much

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

 

StacyCui
Contributor III
Contributor III
Author

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

StacyCui_3-1669347162481.png

 

StacyCui
Contributor III
Contributor III
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
Contributor III
Contributor III
Author

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