Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional count in charts

I have a problem implementing the following in QlikView (10)

I'm trying to count persons with a specific number of actions and visualize those values in a chart.

count(distinct person_id) where no_of_actions = 1

count(distinct person_id) where no_of_actions = 2

count(distinct person_id) where no_of_actions = 3

...

I calculate the number of actions using an if-statement:

if(item_typ=action, sum(action_quantity))

The "normal" way I see conditional count is

count(distinct if(no_of_actions=1), person_id)

I would however need to integrate the if-statement, because no_of_actions doesn't exist as a field, but is only calculated (also the number of actions should be seen per person). How can I achieve this?

1 Solution

Accepted Solutions
Not applicable
Author

I solved it. It should be:
count(distinct {$<person_id= {“=sum({<item_typ='action'>}action_quantity) = 1”}>} person_id)

View solution in original post

5 Replies
jvitantonio
Specialist III
Specialist III

Can you specify what no_of_actions is? A Variable? Try using set analysis. IF statement has an impact on performance.

count( {$<no_of_actions = {1}>} DISTINCT person_id )

Not applicable
Author

Hi,

Try this:

count( {$<person_id= {“=sum({<item_typ={"action"}>}action_quantity) = 1”}>} distinct person_id)

count( {$<person_id= {“=sum({<item_typ={"action"}>}action_quantity) = 2”}>} distinct person_id)

count( {$<person_id= {“=sum({<item_typ={"action"}>}action_quantity) = 3”}>} distinct person_id)


succes,

Halmar

Not applicable
Author

no_of_actions is something I calculate, it's actually kind of non-existent
as mentioned above it's calculated: if(item_typ=action, sum(action_quantity))

Not applicable
Author

Hello Halmar,


This looks like what I am looking for. I get a syntax error however, when I try to use it.


count(
{$<person_id = {“=sum({<item_typ={"action"}>}action_quantity) = 1”}>} distinct person_id)


Unfortunately I am not familar enough with set analysis to solve it myself.


Susann

Not applicable
Author

I solved it. It should be:
count(distinct {$<person_id= {“=sum({<item_typ='action'>}action_quantity) = 1”}>} person_id)