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: 
Arno
Contributor II
Contributor II

total result strange when using if()

Dear all,

in my master data I have 1 row with where I differ the data by either "spot" or "contract".

Depending on this condition I woul like to use a different calculation method (see attached pivot).

On the condition level it looks fine. The total volue however is not correct.

Do you see where my mistake is (I am quite fresh in qlik)?

Many thanks in advance

 

1 Solution

Accepted Solutions
marcus_sommer

You need an aggr() to get the sum of all rows within the total. This means:

sum(aggr(YourExpression, Dim1, Dim2))

whereby Dim1 and Dim2 are placeholder for the dimensions in which context the calculation should be executed. In your case surely the spot/contract dimension but probably also the year and month dimension, too.

- Marcus

View solution in original post

4 Replies
rodri_morales
Creator II
Creator II

Hi Arno,

I don't know what is the problem the total is not working. But I see you have more than one dimension, maybe there is a value that can be "OK" for two different dimension, so in the total will be sum twice.

A better solution is create a new field using the condition "IF". Then you only has to sum that field.

marcus_sommer

You need an aggr() to get the sum of all rows within the total. This means:

sum(aggr(YourExpression, Dim1, Dim2))

whereby Dim1 and Dim2 are placeholder for the dimensions in which context the calculation should be executed. In your case surely the spot/contract dimension but probably also the year and month dimension, too.

- Marcus

Arno
Contributor II
Contributor II
Author

Hi Marcus,

this is exactly what I was looking for. Really good solution. 

Many thanks and best regards

Arno

Arno
Contributor II
Contributor II
Author

Hi Rodri,

thans for your fast feedback. I have already taken the solution offerd by Marcus, and this is fine for my purpose.

I will try your solution later on, too  in order to get more familiar with qlik.

Best regards

Arno