Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Calculating average of two percentages.

Hi there,

Is there an easy way to determine the average of two percentage values? In the example below I want to determine the average of pie chart 1 and 2. Ive set the pie chart on option 'relative' so that it shows the percentages of the actual values. (the pie charts below it)

But now I want to determine the average of those percentages.  (% + %  ) /2 = average%

But this cannot be done because the actual values qlikview calculates with are the real values in the graphs below it. Therefor giving faulty percentages. How can I do this>?

why.png

1 Solution

Accepted Solutions
MVP
MVP

Re: Calculating average of two percentages.

'Relative' does the following calculation:

       Count({<operator={'T'}>}  object) / Count({<operator={'T'}>} TOTAL object)

Your average will probably be:

=( Count({<operator={'T'}>}  object) / Count({<operator={'T'}>} TOTAL object) +

Count({<operator={'O'}>}  object) / Count({<operator={'O'}>} TOTAL object) ) / 2



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
6 Replies

Re: Calculating average of two percentages.

what is the expression for %?

MVP
MVP

Re: Calculating average of two percentages.

You will have to calculate the average in full for the 3rd pie chart - it is not possible to get the calculation results from the other charts.

BTW - I think a pie chart is always relative - all that selecting relative would change is how the numbers are displayed in the legend and in the chart itself (if that option is enabled).

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Calculating average of two percentages.

expresion:        Count({<operator={'O'}>}  object)

dimension:       Number

So it counts the amount of objects to the Number dimension.

For the second pie chart

expresion:        Count({<operator={'T'}>}  object)

dimension:       Number

Now in my third pie chart I want the average of the two percentages of the O and T operator.

Now I did: (which is totally wrong)

expresion           count( {<operator={'O','T'}>} object)

dimesnion:          Number

The relative checkbox, makes the actual values change to percentages. But I cannot reuse those percentage as Jonathan says. I was wondering if there was an option for that. Seems I have to calculate the number by hand then.

Re: Calculating average of two percentages.

Can you post some sample data with expected output?

MVP
MVP

Re: Calculating average of two percentages.

'Relative' does the following calculation:

       Count({<operator={'T'}>}  object) / Count({<operator={'T'}>} TOTAL object)

Your average will probably be:

=( Count({<operator={'T'}>}  object) / Count({<operator={'T'}>} TOTAL object) +

Count({<operator={'O'}>}  object) / Count({<operator={'O'}>} TOTAL object) ) / 2



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Calculating average of two percentages.

Yes this is indeed correct.

Makes sense now thank you.

Community Browser