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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Exclude duplicates

Hi

I have to fields, NumberofChildren and ID.

Because the ID occurs multiple times the sum(numberofchildren) shows wrong. I want to distinct them so it only sum it ones.

And, does that don´t have a children are marked as 0.

How can I do that?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

=sum({$-< NumberOfChildren = {0} >} aggr(NumberOfChildren, ID))

View solution in original post

7 Replies
sreenivas
Creator III
Creator III

In the Expression instead of Sum use ONLY

its_anandrjs
Champion III
Champion III

Hi,

Use Distinct with Sum function like Sum(Distinct numberofchildren).

Thanks Rgds

Not applicable
Author

Hello ,

the possible is two: from script from  report:

from script

TAB:

noconcatenate

LOAD ID,

          NAME,

AVG(Number of cildren)  ------------------------>(OR dISTINCT( nUMBEr OF cILDREN))

Resident INL

group by

                ID,

          NAME;

FROM REPORT:

IN THE EXPRESSION oNLY(Number of cildren) OR  sum(distinct Number of Cildren)

Not applicable
Author

=Only({$}NumberOfChildren) works but how do I then sum them? I´d like to se the total number of children.

Edit: sum(distinct Number of Cildren) wont work because the it only count the value of say 2 children ones, but several person can have 2 children.

If 2 people have 2 children I want to get the result of 4. The problem is that I some how have to distinct the ID in the sum so it only count the children ones per person.

swuehl
MVP
MVP

Try

=sum({$-< NumberOfChildren = {0} >} aggr(NumberOfChildren, ID))

Not applicable
Author

Why not do something simple like : -

Sum(NumberOfChildren) / Count(ID)

Not applicable
Author

Thanks swuehl. Thats perfect!