Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannagr
Creator III
Creator III

more than one selections in a filter: calculation

Hi all.

I have a filter pane with the values,say, pink, yellow, blue

and a kpi that calculates count(distinct ItemID)

If i select pink the count is 56

If i select yellow the count is 40

but if i select pink and then yellow (so if i make two selections and let's suppose an item can be two colours at once, that's because i can't share my data) the result is 94. 

I thought the calculation was just addition, ignoring if there are already pink items in the yellow that have already been calculated when selected "pink". Is it something like A+B-(A intersection B) ?

7 Replies
Kushal_Chawda

So you want to count ItemIds having both "pink" & "yellow"?

ioannagr
Creator III
Creator III
Author

Hi @Kushal_Chawda ,I want to know what's the calculation behind two selections in a filter pane.

I thought it did, all of them who are pink AND all of them who are yellow, not accounting for intersections.

I was expecting 96.

Kushal_Chawda

Default is "OR" so it will look for all ID's where there is either "pink" or "yellow"

StarinieriG
Partner - Specialist
Partner - Specialist

If you want yellow + pink, you have to use aggr function.

For example: Sum(Aggr(count(distinct ItemID), colour field))

ioannagr
Creator III
Creator III
Author

I see. so what you are saying is that if there's any items that could fall in both categories then they are ignored and not calculated?  And that's why it's 94 and not 96?

StarinieriG
Partner - Specialist
Partner - Specialist

Using count distinct, you count all distinct items (no matter if they exist only yellow, pink or both).

Example

A - yellow

A - pink

B - yellow

C - pink

 

You have A, A, B, C so a count distinct will show 3.

But if you select yellow or pink, you'll have 2.

Kushal_Chawda

It will count that as well but as you are using distinct keyword it will count single instance of ID