Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Set Analysis with selection not working as expected

Hello,

I am trying to understand set analysis, but it doesn't seem to work as I expect when I make a selection. Here is my data:

Residences:

LOAD * INLINE [

Residence_ID, address, type

1, 123 Main St, Apartment

2, 234 Bay St, House

3, 345 Second St, Apartment

4, 456 Oak St, House

];

People:

LOAD * INLINE [

Name, gender, Residence_ID

JOHN SMITH, M, 4

ROBERT JOHNSON, M, 3

MICHAEL MILLER, M, 1

WILLIAM BROWN, M, 4

DAVID JONES, M, 1

RICHARD WILLIAMS, M,2

MARY DAVIS, F, 3

PATRICIA ANDERSON, F, 2

LINDA WILSON, F, 4

BARBARA MARTIN, F, 3

ELIZABETH TAYLOR, F,1

JENNIFER MOORE, F, 3

];

Then I create a bar chart with dimension of gender and measure of count({$<type={'Apartment'}>} Name)

So I only want my chart to count the number of people living in apartments.

If I then select to just show item of type House, I expected my chart to be blank, because $ represents the current selection and there is nothing of type "Apartment" in that selection; however, it does not change.

Can someone explain this?

Thanks,

Tanya

1 Solution

Accepted Solutions
sunny_talwar

I think you need this:

Count({$<type * = {'Apartment'}>} Name)


Implicit Set Operators

View solution in original post

5 Replies
andrespa
Specialist
Specialist

Hi Tanya, actually is quite the opposite, you're forcing that no matter the selection, you will always have the number of people living in apartments.

Cheers,

Andrés

antoniotiman
Master III
Master III

Hi Tanya,

try

count({$<type-={'House'}>} Name)

gferran
Partner - Contributor III
Partner - Contributor III

Tanya,

in the set analysis you are using:

- $: to respect the current selections

- type={'Apartment'}: the bar chart always show the type apartment despite you select another type

For mor information about set analysis: https://community.qlik.com/docs/DOC-4951

Regards

sunny_talwar

I think you need this:

Count({$<type * = {'Apartment'}>} Name)


Implicit Set Operators

Anonymous
Not applicable
Author

I wish I could select multiple responses as correct. Andres, yours explained the behaviour I was seeing and Sunny T explained how to get the behaviour I was expecting!

Thanks everyone!