Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
msshawn3019
Contributor II
Contributor II

Sum if greater than 0 else 0

How to Sum DATA if greater than 0, else display $0

Basic algorithm:  If (Sum(DATA)>0, Sum(DATA), 0)

Using something like this:

Sum({<[CyclePeriod]=>}DATA), [ClientId],[ClientName],[Account],[CyclePeriod])

Labels (1)
1 Solution

Accepted Solutions
msshawn3019
Contributor II
Contributor II
Author

I ended up doing it like thig:

If (Sum( {< [Billing Cycle]={">=$(=Max([Billing Cycle])-2)<=$(=Max([Billing Cycle]))"} >} DATA) <>0, Sum( {< [Billing Cycle]={">=$(=Max([Billing Cycle])-2)<=$(=Max([Billing Cycle]))"} >} DATA)

View solution in original post

4 Replies
vinieme12
Champion III
Champion III

You already have the solution

if(Sum({<[CyclePeriod]=>}DATA)>0,Sum({<[CyclePeriod]=>}DATA),0)

 

Are you doing any aggregations using AGGR()

Can you provide more details such as dimensions used in chart and copy paste your actual expression

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

I think I need to do aggregations in the solution - by [ClientId],[ClientName],[Account],[CyclePeriod]

As I have multiple clients, accounts and Month/Year periods for my pivot table

msshawn3019
Contributor II
Contributor II
Author

Something like this but it's not giving a 0 when there is no value (DATA) for a given period, client, account:

=If (sum(aggr(sum({<[CyclePeriod]=>}DATA),[ClientId],[ClientName],[Account],[CyclePeriod])) > 0,
sum(aggr(sum({<[CyclePeriod]=>}DATA),[ClientId],[ClientName],[Account],[CyclePeriod])), 0)

msshawn3019
Contributor II
Contributor II
Author

I ended up doing it like thig:

If (Sum( {< [Billing Cycle]={">=$(=Max([Billing Cycle])-2)<=$(=Max([Billing Cycle]))"} >} DATA) <>0, Sum( {< [Billing Cycle]={">=$(=Max([Billing Cycle])-2)<=$(=Max([Billing Cycle]))"} >} DATA)