Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
EliGohar
Partner - Creator III
Partner - Creator III

Count with Set analysis - AND combination for same dimension

Hi All,

I'm trying to count unique faces (FaceID field) which appeared both in “Left wing” and “Exit 1” Sources, this is a sample data:

EliGohar_1-1597150744197.png

if I’m using this expression:

count(distinct {$<[Source]={'Left Wing','Exit 1'}>} FaceID)

I’ll get 2 (because it calculates faces which appeared in “Exit 1” or “Left Wing”)

I'm expecting to get 1 because only faceID 2190 appeared both in "Exit 1" and "Left Wing"

Thanks for the help,

Eli.

2 Solutions

Accepted Solutions
sunny_talwar

Sorry my bad, try this instead

Count(DISTINCT {$<FaceID = P({<[Source] = {'Left Wing'}>}) * P({<[Source] = {'Exit 1'}>})>} FaceID)

changed '+' (union) to '*'  (intersection)

View solution in original post

lironbaram
Partner - Master III
Partner - Master III

hi @EliGohar 
strange , have a look at the attach app ,
this expression work as expected 

View solution in original post

9 Replies
sunny_talwar

Try this

Count(DISTINCT {$<FaceID = P({<[Source] = {'Left Wing'}>}) + P({<[Source] = {'Exit 1'}>})>} FaceID)
EliGohar
Partner - Creator III
Partner - Creator III
Author

@sunny_talwar Thanks but it still counts faces which appeared in “Exit 1” or “Left Wing”.

sunny_talwar

Sorry my bad, try this instead

Count(DISTINCT {$<FaceID = P({<[Source] = {'Left Wing'}>}) * P({<[Source] = {'Exit 1'}>})>} FaceID)

changed '+' (union) to '*'  (intersection)

EliGohar
Partner - Creator III
Partner - Creator III
Author

@sunny_talwar You Rock!

EliGohar
Partner - Creator III
Partner - Creator III
Author

@sunny_talwar I have another question:

I want to add another condition:

Count unique faces (FaceID field) which appeared both in “Left wing” and “Exit 1” Sources and not appeared in "Entrance 2" source.

Tried the following expression:

Count(DISTINCT {$<FaceID = P({<[Source] = {'Left Wing'}>}) * P({<[Source] = {'Exit 1'}>}) * P({<[Source] -= {'Entrance 2'}>})>} FaceID)

 

But no luck.

Any idea?

Thanks.

lironbaram
Partner - Master III
Partner - Master III

hi 
try this 

Count(DISTINCT {$<FaceID = P({<[Source] = {'Left Wing'}>}) * P({<[Source] = {'Exit 1'}>}) - P({<[Source] = {'Entrance 2'}>})>} FaceID)
EliGohar
Partner - Creator III
Partner - Creator III
Author

@lironbaram  

Tried it, it keeps counting people who visited all 3 areas, for example:

EliGohar_0-1598423908208.png

lironbaram
Partner - Master III
Partner - Master III

hi @EliGohar 
strange , have a look at the attach app ,
this expression work as expected 

EliGohar
Partner - Creator III
Partner - Creator III
Author

@lironbaram Thanks!