5 Replies Latest reply: Sep 28, 2016 8:24 AM by Tanya Ruppell

# 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 [

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

• ###### Re: Set Analysis with selection not working as expected

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

• ###### Re: Set Analysis with selection not working as expected

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!

• ###### Re: Set Analysis with selection not working as expected

Hi Tanya,

try

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

• ###### Re: Set Analysis with selection not working as expected

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

• ###### Re: Set Analysis with selection not working as expected

I think you need this:

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

Implicit Set Operators