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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
apthansh
Creator
Creator

count based on possible values

 

Hi - I have table as below.

IDType
1Active
1Inactive
2Active
2Pending

 

I have to get count of ID on each type -Active, Inactive, Pending but If ID has both Active & Inactive I only want to include the count in Active group.

Based on the data, below would be the counts, I want to show it in the KPI.

Active - 2

Inactive - 0

pending - 1

Thank you much.

Labels (1)
2 Solutions

Accepted Solutions
sunny_talwar
MVP
MVP

May be try this also

Sum(Aggr(If(Count(DISTINCT TOTAL <ID> {<Type = {'Active', 'Inactive'}>} Type) = 2 and Type = 'Inactive', 0, 1), ID, Type))

With Type as your dimension. 

View solution in original post

sunny_talwar
MVP
MVP

#Active - Count(DISTINCT {<Type *= {'Active'}>} ID)

#InActive - Count(DISTINCT {<Type *= {'Inactive'}, ID *= e({<Type={'Active'}>})>} ID)

#Pending - Count(DISTINCT {<Type *= {'Pending'}>} ID)

View solution in original post

5 Replies
tresB
Champion III
Champion III

Inactive :

 =Count(DISTINCT {<Type={'Inactive'},ID=e({<Type={'Active'}>})>}ID)

sunny_talwar
MVP
MVP

May be try this also

Sum(Aggr(If(Count(DISTINCT TOTAL <ID> {<Type = {'Active', 'Inactive'}>} Type) = 2 and Type = 'Inactive', 0, 1), ID, Type))

With Type as your dimension. 

apthansh
Creator
Creator
Author

@sunny_talwar Thank you - This gave me a total count which is correct.I want to put this in the KPI for each type.

#Active - 

#InActive - 

#Pending - 

 

Thank you.

sunny_talwar
MVP
MVP

#Active - Count(DISTINCT {<Type *= {'Active'}>} ID)

#InActive - Count(DISTINCT {<Type *= {'Inactive'}, ID *= e({<Type={'Active'}>})>} ID)

#Pending - Count(DISTINCT {<Type *= {'Pending'}>} ID)

apthansh
Creator
Creator
Author

you are awesome.Thank you.