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: 
davyqliks
Specialist
Specialist

Sum total not equal to expected value

Hi All,

Looking at the below table, (Left) when i have the dimension Fibres my total is equal to 600 as expected.

(Right) When i remove the Fibres dimension and use set analysis, one of the values of 60 is not calculating giving me 60 short of the total expected. 

Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight)

Sum( distinct {<SustainableLevel = {'Not Sustainable'}>}Weight)

davyqliks_0-1648647927585.png

How can i get the total on the right table for the following:

Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight)

To include the other 60 to give me the 420.

 

I also tried an Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres) but i get a null return.

Thank you in advance.

 

Daniel

Labels (4)
1 Solution

Accepted Solutions
brunobertels
Master
Master

Well not sure to be helpful in that case 

seems that you use distinct because sustainableLevel is repeated by Portal Order number 

 

try this 

Sum( distinct {<SustainableLevel = {'Sustainable'}>} total Weight)

or this 

Sum( total <Fibres> distinct {<SustainableLevel = {'Sustainable'}>}Weight)

or

 sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres) )

View solution in original post

12 Replies
brunobertels
Master
Master

Hi 

you have 3 sustainable value 2*60 1* 300 

using distinct you will get 

1* 60

1* 300 

try using this 

Sum( {<SustainableLevel = {'Sustainable'}>}Weight)

davyqliks
Specialist
Specialist
Author

Hi There,

Thank you for the reply, see and didnt consider this.

My issue is that when not using distinct the value is way out! this is a copy of the right table in the previous image:

davyqliks_0-1648649125346.png

 

Any ideas why?

i have no synthetic keys.

Thank you so much for the reply.

Daniel

 

 

davyqliks
Specialist
Specialist
Author

HI All,

I just dont get this.

 

For a selected order i see here i have 3*130 and 1*260 weight.

Sum(Distinct Weight)  390 as expected

Sum(Weight) 21883680

See on the right table all data for this order... Can anyone shed some light on this?

davyqliks_1-1648651704042.png

Thank you, i'm losing my mind here 🙂

 

Kind regards,

Daniel

 

brunobertels
Master
Master

Well not sure to be helpful in that case 

seems that you use distinct because sustainableLevel is repeated by Portal Order number 

 

try this 

Sum( distinct {<SustainableLevel = {'Sustainable'}>} total Weight)

or this 

Sum( total <Fibres> distinct {<SustainableLevel = {'Sustainable'}>}Weight)

or

 sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres) )

davyqliks
Specialist
Specialist
Author

Absolute legend Bruno,

Thank you so much for sharing your time and expertise with me, option 3 was the one i was looking for,

davyqliks_0-1648652313047.png

Thank you

Daniel

 

 

davyqliks
Specialist
Specialist
Author

HI Again Bruno,

I have one more slight issue with the given solution.

when i un filter, all are showing the same value

davyqliks_1-1648652741997.png

But when i make a selection the result is correct, different example below

davyqliks_2-1648652796760.png

Do you know why this is and how i can resolve? thanks and apologies for coming back to you on this.

Daniel

 

brunobertels
Master
Master

Hi 

Add dim Portal Order No in your agregation : 

may be this 

sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres, "Portal Order No" ) )

davyqliks
Specialist
Specialist
Author

HI Bruno,

I did try this before coming back to you with the same result.

sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres, "Portal Order No." ) )

davyqliks_0-1648653854462.png

 

Any other ideas?

 

Thanks again.

Daniel

brunobertels
Master
Master

Nope 😞 

but this may be 

aggr(

sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres) )

, "Portal Order No." )

or 

Sum(

aggr(

sum( total Aggr(Sum( distinct {<SustainableLevel = {'Sustainable'}>}Weight),Fibres) )

, "Portal Order No." )