Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum using distinct

Hi,

This is a snip of my data:

Udklip.JPG

I need to sum "Crop" and in this example my choice is 'Cereal'. I need to look at the ID and Spieces as well.

ID 1 has one field with the size 10 (Cereal + Spring Barley) and one field with the size 12 (Cereal + Winter barley). This total field size is then 22 for Cereal.

ID 2 has one field with the size 10 (Cereal + Winter wheat) and one field with the size 15 (Cereal + Oat) and one field with the size 20 (Cereal + oat) and finally one field with the size 20 (Cereal + Winter wheat). his total field size is then 67 for Cereal.

All in all it's 87 for Cereal.

How does the syntax for a new measure looks ?

Cheers,

Kenneth

1 Solution

Accepted Solutions
Gysbert_Wassenaar

That's not necessary in this case, but if you want you can add the ID field to the field list in the aggr function:

=sum(aggr(sum({<Crop={'Cereal'}>} distinct Fieldsize),Crop,Spieces,ID))


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

Try sum(aggr(sum({<Crop={'Cereal'}>} distinct Fieldsize),Crop,Spieces))


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks but I think I need to take the ID into consideraton as well ?

Gysbert_Wassenaar

That's not necessary in this case, but if you want you can add the ID field to the field list in the aggr function:

=sum(aggr(sum({<Crop={'Cereal'}>} distinct Fieldsize),Crop,Spieces,ID))


talk is cheap, supply exceeds demand