Jump to content
We've recently updated our Privacy Statement, available here. ×

How to count categories that satisfy a predicate


Antoine Doeraene

Recommended Posts

Hello,

I'd like to write a custom expression to insert in a Calculated value within a text area or a graphical table that, in a nutshell, counts the number of categories that satisfy some aggregation critera.

For example, imagine that I have a table with two columns: Category (of type String)and Value (of type Double). I would like a formula that computes the number of categories for which, for example, the number of different categories for which they average is bigger than, say, 0.

 

Example:

If the data set is

Category Value

A 3

B -1

A -1

B 0.5

 

Then the number I want to have is 1, since B has average -0.25 while A has average 1.

How could I do that

Thanks.

Link to comment
Share on other sites

Indeed, that works to know whether each category satisfy what I want.But now, how do I do to count how many satisfy this In a Calculated Value of a text area, I would like to do

Sum(If(Avg([Value]) over [Category] > 0, 1, 0))but that is apparently not correct.Or is it a way to apply custom expressions on the results of a graphical table That would be awesome...

Link to comment
Share on other sites

There is no grand total option in graphical table so you cant count it. You need to use Cross Table to archieve what you trying to do. Same steps. In cross table > properties > Grand total > under Calculate totals, select As the sum of cell values.

 

If you want to show the sum total in a text area then you have to create a calculated column first. Then use the calculated value under Insert Dynamic Item in text area to sum the values in the calculated column.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...