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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression to sum only positive amounts

I have a column in a straight table with positive and negative monetary amounts.  I want to sum only the positive amounts and exclude the negative amounts from the total.  Do you know the proper expression to use? 

7 Replies
tresesco
MVP
MVP

From the total of the same straight table column?

Not applicable
Author

correct. thanks

anbu1984
Master III
Master III

Try this

=if(rowno()=0 or isNull(rowno())

  ,Sum(If(Sales>0,Sales))

  ,Sum(Sales)

)

tresesco
MVP
MVP

May be like attached sample.

=If( RowNo()=0 or IsNull(RowNo()), Sum(Aggr(If(Sum(amt)>0,Sum(amt)),Listvalue)), Sum(amt))

tresesco
MVP
MVP


Anbu, your solution works on individual member of Sales not on aggregated amount, so it gives a different result.

Not applicable
Author

do you want to display -ve number in that column if not you can convert -ve number into zero by using if condition and you will get the sum of only positive numbers

=if(sum(amt)<0,0,sum(amt))

and to show all dimensions you can uncheck option suppress zero value in chart properties presentation tab

-Rajendra

Anonymous
Not applicable
Author

Hello, Erica.

I would try this expression:

if(Dimensionality() = 0, Sum(if(Value > 0, Value)), Sum(Value))

Dimensionality() equal 0 when it's the total row.

Regards.