Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mauvasco62
Contributor III
Contributor III

sum if sum?

Dear all,

i need you support in order to calculate a misure (in a table).

The problem is this: i have this formula 

SUM([IMPORTO TOTALE])

with related dimensions (Month, Year, Customer) but in some cases the final result is = 0 and i don't want to see that.

I tried to use this IF(Sum([IMPORTO TOTALE])>0,SUM([IMPORTO TOTALE])) but without success.

the data I'm going to read for example are these:

 

YEAR     MONTH      CUSTOMER      IMPORTO TOTALE

2020      1                   ALFA                   1.500

2020      1                   ALFA                 -1.500

 

 

1 Solution

Accepted Solutions
JustinDallas
Specialist III
Specialist III

You probably want to use AGGR.  For the dummy data that I've got, I got it to work by having a field in my table like so:

 

=If(AGGR(SUM([IMPORTO TOTALE]),  YEAR, CUSTOMER, MONTH) > 0, YEAR )

 

Along with  unchecking the box labeled "Include Null Values"

 

Dummy Data:

Data:
LOAD * Inline
[
	'YEAR', 'MONTH', 'CUSTOMER', 'IMPORTO TOTALE'
    2020, 1, Pasta, 1500
    2020, 1, Pasta, -1500
    2020, 1, Linguine, 20
    2020, 1, Linguine, 45
]
;

 

JustinDallas_0-1591372327728.png

 

 

Let me know if this helps.

View solution in original post

2 Replies
JustinDallas
Specialist III
Specialist III

You probably want to use AGGR.  For the dummy data that I've got, I got it to work by having a field in my table like so:

 

=If(AGGR(SUM([IMPORTO TOTALE]),  YEAR, CUSTOMER, MONTH) > 0, YEAR )

 

Along with  unchecking the box labeled "Include Null Values"

 

Dummy Data:

Data:
LOAD * Inline
[
	'YEAR', 'MONTH', 'CUSTOMER', 'IMPORTO TOTALE'
    2020, 1, Pasta, 1500
    2020, 1, Pasta, -1500
    2020, 1, Linguine, 20
    2020, 1, Linguine, 45
]
;

 

JustinDallas_0-1591372327728.png

 

 

Let me know if this helps.

mauvasco62
Contributor III
Contributor III
Author

Thanks.

it works fine!

Have a nice week end

Mauro