Forum Discussion
problem reconcile average total
- 9 years ago
If you want the "Grand Total" to be the Average of the Term Average GPAs, then your issue is the one I posted about above. If it is not your issue, please be more specific with what you are looking for.
Let me know if I have recreated your dilemma below:
Here are the DAX formulas for the measures:
Average of Term GPA :=
AVERAGE ( Table1[Term GPA] )Average Term GPA - Fixed :=
AVERAGEX ( VALUES ( Table1[Term Description] ), [Average of Term GPA] )What AVERAGEX does is it iterates over a table, evaluates all the averages, and then averages those results.
VALUES returns a 1 column table of the distinct values in that column currently visible in the filter context.
So what we are doing is using VALUES to return this
Fall 2016
Fall 2017
Winter 2017
Then evaluating [Average of Term GPA] for each term
Fall 2016 3.19
Fall 2017 0.00
Winter 2017 4.00
And finally AVERAGEX averages all of the values we just evaluated.
Fall 2016 3.19
Fall 2017 0.00
Winter 2017 4.00
2.40
Let me know if this works!
Thanks.
My guess is that you are receiving what you asked for, yet are unclear regarding the idea of filter context.
When in a pivot table, the "Total" is calculated separately from the items above it. When the Power Pivot engine is calculating the value for "Total", it does not recognize the numbers it calculated for your individual campuses.
What the engine is doing for each of the campuses is taking your base data, filtering it to only the specific campus, and then calculating. When it calculates the total, it just includes all the campuses. It DOES NOT average the averages.
Look at these two examples (table on the left contains the Average GPAs for all the students within a given campus, as shown on the table on the right)
In this first example, the averages match. This is because the calculations are the same (in regards to the number of students and the cumulative sum of the GPAs. Thus, the "Average of Average GPAs" coincidentally is the same, because each campus has the same number of students.
In this next example, I just added two more students to Campus5, but halved the GPAs for students 19 and 20. Thus, the sum for all the GPAs is the same, but the denominator has changed. So the Average of the Students GPAs is different, while the "Average of the Average Student GPAs" stays the same.
If you want to force Power Pivot to calculate the Average of the Campus Average GPAs, you can force it to do so. Please post your measure and we can tweak it to take the Average of all the Campus Average GPAs for the "Totals" row.
Let me know if any of this is unclear--Thanks!
Ben
Hopefully this is sufficient as a sample. This will look different from my original post as that was quite lengthy.
| Average of Term GPA | Column Labels | ||||||
| Row Labels | Campus1 | Campus2 | Campus3 | Campus4 | Campus5 | Campus6 | Grand Total |
| Course X | 2.60 | 3.40 | 3.40 | 3.20 | 3.60 | 2.00 | 3.03 |
| Fall 2016 | 2.60 | 3.40 | 3.40 | 3.20 | 3.50 | 3.00 | 3.19 |
| Fall 2017 | 0.00 | 0.00 | |||||
| Winter 2017 | 4.00 | 4.00 | 4.00 | ||||
| Grand Total | 2.60 | 3.40 | 3.40 | 3.20 | 3.60 | 2.00 | 3.03 |
| ID1 | Term Description | Campus | Course Name | Term GPA |
| Student1 | Fall 2016 | Campus1 | Course X | 4 |
| Student2 | Fall 2016 | Campus1 | Course X | 2 |
| Student3 | Fall 2016 | Campus1 | Course X | 1 |
| Student4 | Fall 2016 | Campus1 | Course X | 3 |
| Student5 | Fall 2016 | Campus1 | Course X | 3 |
| Student29 | Fall 2016 | Campus2 | Course X | 4 |
| Student30 | Fall 2016 | Campus2 | Course X | 3 |
| Student31 | Fall 2016 | Campus2 | Course X | 4 |
| Student32 | Fall 2016 | Campus2 | Course X | 3 |
| Student33 | Fall 2016 | Campus2 | Course X | 3 |
| Student55 | Fall 2016 | Campus3 | Course X | 3 |
| Student56 | Fall 2016 | Campus3 | Course X | 4 |
| Student57 | Fall 2016 | Campus3 | Course X | 4 |
| Student58 | Fall 2016 | Campus3 | Course X | 3 |
| Student59 | Fall 2016 | Campus3 | Course X | 3 |
| Student92 | Fall 2016 | Campus4 | Course X | 3 |
| Student93 | Fall 2016 | Campus4 | Course X | 3 |
| Student94 | Fall 2016 | Campus4 | Course X | 4 |
| Student95 | Fall 2016 | Campus4 | Course X | 3 |
| Student96 | Fall 2016 | Campus4 | Course X | 3 |
| Student149 | Fall 2016 | Campus5 | Course X | 3 |
| Student150 | Fall 2016 | Campus5 | Course X | 4 |
| Student151 | Fall 2016 | Campus5 | Course X | 3 |
| Student152 | Winter 2017 | Campus5 | Course X | 4 |
| Student153 | Fall 2016 | Campus5 | Course X | 4 |
| Student189 | Fall 2017 | Campus6 | Course X | 0 |
| Student190 | Fall 2017 | Campus6 | Course X | 0 |
| Student191 | Winter 2017 | Campus6 | Course X | 4 |
| Student192 | Fall 2016 | Campus6 | Course X | 4 |
| Student193 | Fall 2016 | Campus6 | Course X | 2 |
- bdymit9 years agoResolver II
If you want the "Grand Total" to be the Average of the Term Average GPAs, then your issue is the one I posted about above. If it is not your issue, please be more specific with what you are looking for.
Let me know if I have recreated your dilemma below:
Here are the DAX formulas for the measures:
Average of Term GPA :=
AVERAGE ( Table1[Term GPA] )Average Term GPA - Fixed :=
AVERAGEX ( VALUES ( Table1[Term Description] ), [Average of Term GPA] )What AVERAGEX does is it iterates over a table, evaluates all the averages, and then averages those results.
VALUES returns a 1 column table of the distinct values in that column currently visible in the filter context.
So what we are doing is using VALUES to return this
Fall 2016
Fall 2017
Winter 2017
Then evaluating [Average of Term GPA] for each term
Fall 2016 3.19
Fall 2017 0.00
Winter 2017 4.00
And finally AVERAGEX averages all of the values we just evaluated.
Fall 2016 3.19
Fall 2017 0.00
Winter 2017 4.00
2.40
Let me know if this works!
Thanks.
- chartford9 years agoRegular Visitor
Clearly I've got some additional research to do but you've certainly provided a glimpse into how this process works. Thanks for the assistance.
- bdymit9 years agoResolver II
Happy to help.
The clearest, easiest outline to understand how the DAX engine is evaluating measures is this reference card.
https://powerpivotpro.com/2015/10/giving-back-steal-this-reference-card/
It explains concepts like filter context, which I mentioned.
Here are other helpful resources.
https://www.youtube.com/watch?v=a29YqDosRYY&t=241s
https://www.youtube.com/watch?v=29frZhkwCqQ
https://www.youtube.com/watch?v=z96HqHvoZNg
https://www.youtube.com/watch?v=klQAZLr5vxA&t=34s
https://www.youtube.com/watch?v=6ncHnWMEdic&t=45s
Best of luck!