1 Reply Latest reply: Nov 9, 2018 1:27 PM by Stefan Wühl

# 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

• ###### Re: Count function counts everything irrespective of the condition

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)