Skip to main content

Hello all,

 

I would like to compare how certain attributes of selected cases compare to the overall share of cases with that attribute.

 

For example:

All cases have a certain color. I would like to know what is the share of each color for my selected cases compared to the share of that color for all cases.

 

The result should look like (simplified):

Color | Selected Cases | All Cases | Difference

red | 15% | 30% | -15%

green| 85% | 70% | 15%

 

Therefore I created a OLAP table with the dimension "color" and the following KPIs:

 

The KPI for my selected cases is:

(COUNT ( DISTINCT "table"."case_id" ) / GLOBAL(COUNT ( DISTINCT "table"."case_id" )))

-> works fine

 

For all cases the KPI is:

PU_COUNT_DISTINCT (DOMAIN_TABLE ("table"."color"), "table"."case_id") /

PU_COUNT_DISTINCT ( CONSTANT(), "table"."case_id")

-> which also works fine

 

But when trying to substract both values from each other (KPI1 - KPI2) to create the difference, the following error occurs:

 

The aggregation function COUNT cannot be used together with a dimension function input. Please check that there are no aggregations and dimensions used together as function inputs.

 

How can I calculate the difference between these two values?

 

Many thanks,

 

Marcus

Hi @marcus.sturs11,

 

I'm not sure whether this works, but you can try to, instead of using COUNT in your first KPI for selected cases an PU_COUNT_DISTINCT with DOMAIN_TABLE to count the amount cases.

 

(PU_COUNT_DISTINCT ( DOMAIN_TABLE ( "table"."case_id" ), "table"."case_id") / GLOBAL(PU_COUNT_DISTINCT ( DOMAIN_TABLE ( "table"."case_id" ), "table"."case_id" )))

 

This would theoretically allow you to bypass the error without using COUNT.

 

Not sure if GLOBAL would work in this setting, so please let me know!

 

Kind regards,

Sverre Klein

 

 


Hello @sverre.klein11 ,

 

many thanks for your response!

 

Unfortunately, that doesn't work as PU functions do not consider current filters. The whole purpose of the analysis is to identify which properties do have the filtered cases in common compared to all cases.

 

Kind regards,

 

Marcus


I think, I did find a solution, even though I don't yet fully understand why.

 

I figured out that PU_COUNT_DISTINCT (DOMAIN_TABLE ("table"."color"), "table"."case_id") does not return 1 value but <Amount of cases for Dimension> times the same value. This does not seem to apply for PU_COUNT_DISTINCT ( CONSTANT(), "table"."case_id").

 

So if color "red" applies to 10 cases, then the value is returned 10 times.

 

Wrapping the PU_COUNT_DISTINCT (DOMAIN_TABLE ("table"."color"), "table"."case_id") or the whole KPI2 statement in a FIRST/LAST function returns one value. Then, the subtraction works.


Reply