# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
cancel
Showing results for
Did you mean:
Contributor III

## Count set analysis does not return expected results

Hi there , I am struggling to understand why my expression gives a wrong result.

I want to calculate customers with event type P whose total events is >= 2. The answer should be 3, but my set analysis giving me 4.

COUNT({<[Event Type]={'P'},
[Customer ID] = {"=sum([Total Events])>=2"}
>}distinct[Customer ID]

The expression seems to ignore the Event Type ='P'.

Thank you

Labels (2)

• ### Set Analysis

1 Solution

Accepted Solutions
MVP & Luminary

Your [Event Type] condition isn't applied to the sum() and therefore there not regarded. You may change your expression like:

COUNT({<[Customer ID] = {"=sum({< [Event Type]={'P'}>} [Total Events])>=2"}
>} distinct[Customer ID]

- Marcus

16 Replies
MVP

i think your expression to be modified like below

COUNT({<[Event Type]={'P'},
[Customer ID] = {"=count([Total Events])>=2"}
>}distinct[Customer ID])

Contributor III
Author

Thanks, @Chanty4u  but that's not correct.

MVP & Luminary

Your [Event Type] condition isn't applied to the sum() and therefore there not regarded. You may change your expression like:

COUNT({<[Customer ID] = {"=sum({< [Event Type]={'P'}>} [Total Events])>=2"}
>} distinct[Customer ID]

- Marcus

Contributor III
Author

Hi @marcus_sommer  thank you so much, it is correct now.

Contributor III
Author

Hi @marcus_sommer , I have another question, for example I want to include  the last 12 month condition to the expression. Like this:

COUNT({<
[Customer ID] = {"=sum({< [Event Type]={'P'}>} [Total Events])>=2"

>} distinct[Customer ID])

is it still correct?

Thank you

Contributor III
Author

The date condition does not pass to the count again 😞 could you please tell me why it is like this ? @marcus_sommer

MVP & Luminary

It's the same like above - the condition must be applied to the sum() or in other words to the inner condition and not to the outer condition, maybe like this:

COUNT({<
[Customer ID] = {"=sum({< [Event Type]={'P'},
[Total Events])>=2"}
>}
distinct [Customer ID])

As far as the comparison is set to >= <= a formatting won't be needed because the evaluation happens on a numeric level - therefore date() was removed.

- Marcus

Contributor III
Author

Hi @marcus_sommer  the express does not return me any results.

MVP & Luminary

What happens if you applies: