Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
wonkymeister
Creator III
Creator III

Average of percentages

Morning,

i'm trying to understand how to calculate the average of a expression of percentages:

TrainingPassedFailedPassed %
Fire Safety2004881%
Data Protection1503083%
First Aid1005066%
Health & Safety1502586%

below this pivot table i'd like to display the average % passed: Average % Passed Result = 79%

Passed expression :

count({$<mandatory_or_optional = {'M'},passed = {'1'}>}1)

Failed expression:

count({$<mandatory_or_optional = {'M'},passed = {'0'}>}1)


Passed % expression:

count({$<mandatory_or_optional = {'M'},passed = {'1'}>}1)/count({$<mandatory_or_optional = {'M'},passed = {'1','0'}>}1)


to get the average % do i have to wrap the % expression with Aggr using the Total function? I'm a bit lost with this!


cheers guys

1 Solution

Accepted Solutions
sunny_talwar

You should be able to use this and enable partial sum for your training dimension

Avg(Aggr(count({$<mandatory_or_optional = {'M'},passed = {'1'}>}1)/count({$<mandatory_or_optional = {'M'},passed = {'1','0'}>}1), Training))

View solution in original post

4 Replies
tresesco
MVP
MVP

If you want to show it in a text box, yes, you can try using aggr() and 'total'. Please let know (and perhaps share a sample qvw) if that doesn't work .

sunny_talwar

You should be able to use this and enable partial sum for your training dimension

Avg(Aggr(count({$<mandatory_or_optional = {'M'},passed = {'1'}>}1)/count({$<mandatory_or_optional = {'M'},passed = {'1','0'}>}1), Training))

swuehl
MVP
MVP

Depends on how you define your average.

It may be enough to just use


=count({$<mandatory_or_optional = {'M'},passed = {'1'}>}1)

/ count({$<mandatory_or_optional = {'M'},passed = {'1','0'}>}1)


i.e. the same expression for the grouped trainings and the total. This will consider the different number of exams in each training, while using the aggr() function, you ignore the different number of exams and just calculate the numeric average of the four percentages.


edit: Guess you are already decided by defining the expected result of 79%...


wonkymeister
Creator III
Creator III
Author

Sunny, perfect, works a treat, thank you!