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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
pravinkumar_s
Partner - Contributor II
Partner - Contributor II

Count function counts everything irrespective of the condition

What I tried was like this,

If(sum(field_1) > sum(field_2), count(distinct Persons) ) / count(distinct Persons)


So that I can get the percentage of persons meeting the condition.But it got the same results. For example,

If(sum(field_1)>sum(field_2),count(distinct Persons))  = 12

count(distinct Persons) = 12


So how can I get the count of Persons who satisfy the condition?


Thanks,

Pravinkumar

1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

Context is always helpful to understand what you are trying to do.

In which context are you using the expression? A chart with (which) dimensions?

I assume you need to create something like a virtual table with dimension Persons, then check your condition to flag the Persons and aggregate the results.

You can use advanced aggregation Aggr() or Set Analysis to do this:

=Sum( Aggr( If(Sum(Field1) >Sum(Field2), 1,0), Persons))

or

=Count({<Persons = {"=Sum(Field1)>Sum(Field2) "}>} DISTINCT Persons)

View solution in original post

1 Reply
swuehl
Champion III
Champion III

Context is always helpful to understand what you are trying to do.

In which context are you using the expression? A chart with (which) dimensions?

I assume you need to create something like a virtual table with dimension Persons, then check your condition to flag the Persons and aggregate the results.

You can use advanced aggregation Aggr() or Set Analysis to do this:

=Sum( Aggr( If(Sum(Field1) >Sum(Field2), 1,0), Persons))

or

=Count({<Persons = {"=Sum(Field1)>Sum(Field2) "}>} DISTINCT Persons)