Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum Distinct

Hi,

I want to make a sum distinct of some values but I can't get right the statement. My table is like this:

Name   Course   Lesson  Duration      +other columns related to lesson

A           Z             1          5

A           Z             2          5

A           Z             3          5

A           Y             1          5

B           Z             1          5

B           W            1          3

I want to know the total duration of all the courses per Name, if I just sum the duration in the case of A for example it will tell me (5+5+5+5) but I only want (5+5) which corresponds to course A and Y. If I just put Sum distinct of duration in the case o A it gives me 5 and doesn't considerate both courses.

I want the following output:

Name      TotalDuration

A              10

B              8

I wonder I have to make some magic on the script. I'm attaching the file. Thanks for your help

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

TableResult.pngYou can use

=Sum(Aggr(sum(DISTINCT Duration),Nombre,Course))

View solution in original post

8 Replies
MK_QSL
MVP
MVP

but I only want (5+5) which corresponds to course A and Y

Y is course???

Please clarify !

Anonymous
Not applicable
Author

Does that mean you only wish to sum() where Lesson = 1 ?

Not applicable
Author

Sorry, it was "which corresponds to course Z* and Y"

Thanks

stigchel
Partner - Master
Partner - Master

TableResult.pngYou can use

=Sum(Aggr(sum(DISTINCT Duration),Nombre,Course))

ramoncova06
Partner - Specialist III
Partner - Specialist III

this should work

sum(Aggr(sum(DISTINCT Duration),Course,Nombre))

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try: sum(aggr(max(Duration),Name,Course))


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Hi,

try with expression:

=sum(aggr(DISTINCT Duration, Nombre, Course))

Regards.

Not applicable
Author

Thank you!!! Apparently it was an easy question. My apologies, I'm new in QlikView