Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jshaw
Frequent Visitor

Count of Average by Group - Pie Chart

I am trying to make a piechart with the following data. 

 

IDSubjectGroupSub GroupRating
1MathAA-11
2MathAA-12
3MathAA-13
4MathAA-11
2ScienceBB-14
4ScienceBB-11
3ScienceBB-13
1ScienceBB-13
4ReadingAA-22
1ReadingAA-22

 

I want to take the average rating for each unique ID, and then the display the count of the average for each ID, in a pie chart, grouped by rating.

 

So essentially, I want to show how many IDs have an average of each rating.  (So my pie chart would have 4 sections, and the values would add up to the distinct number of ID). However, I also need to be able to filter by subject, then by group, and then by sub group.  

 

EDIT: 

Here is what I have so far.

Capture.PNG

 

Here is the data set I am using.

IDSubjectGroupSub GroupRating
1MathAA-11
2MathAA-12
3MathAA-13
4MathAA-11
5MathAA-14
6MathAA-13
2ScienceBB-14
4ScienceBB-11
3ScienceBB-13
1ScienceBB-14
5ScienceBB-12
6ScienceBB-11
4ReadingAA-22
1ReadingAA-22
2ReadingAA-23
3ReadingAA-24
5ReadingAA-21
6ReadingAA-22
2MathLL-11
3MathLL-13
1MathLL-14
4MathLL-12
5MathLL-14
6MathLL-13

 

This is my measure I am using to calculate the average of Rating, based on the ID column.

 

Average of Rating average per ID = 
AVERAGEX(
	VALUES('Sheet1'[ID]),
	CALCULATE(AVERAGE('Sheet1'[Rating]))
)

 

This is the measure I am using to Count, each ID based off their average rating. (I have 4 of these measures, one for each rating)

 

CountOf1 = CALCULATE(DISTINCTCOUNT(Sheet1[ID]), FILTER(Sheet1,[Average of Rating average per ID] = 1))

 

Everything works as expected, except for the Pie chart.  The pie chart is showing the count of everything, and I need it to be grouped by unique IDs.  So in the Pie chart, I would expect the "CountOf3" section to show a value of 4.  And I would expect the "CountOf2" section, to show the value of 2.  ("CountOf1" and "CountOf4" sections would be 0, and not show in the pie chart)

 

14 REPLIES 14
Dgo1973
Regular Visitor

I am having a similar issue.

I have rows of data with %'s.

I want to group the rows of data by Divsion on a pie chart and have set up the pie chart to do a wighted avaerge of the %. but insted i get this:

 

Dgo1973_0-1677628083294.png

 

 

There has to be a setting on the pie chart that i am missing, that is preventing me from getting the results I want

 

here's with weighted average, similar result 🙄

Sum of Standard Hours Efficiency weighted by Average of Standard Hours Efficiency per DIVI =
VAR __CATEGORY_VALUES = VALUES('DBS WOPHDRS0'[DIVI])
RETURN
    DIVIDE(
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(
                SUM('DBS WOPSEGS0'[Standard Hours Efficiency])
                    * AVERAGE('DBS WOPSEGS0'[Standard Hours Efficiency])
            )
        ),
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(AVERAGE('DBS WOPSEGS0'[Standard Hours Efficiency]))
        )
    )
 
Dgo1973_1-1677628785964.png

 

 

 

 

help?

Hi,

Share some data, explain the question and show the expected result in a simple Table format.  From there we canbuid any viz we want.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

so here is the data for one of the 4 Divisions, ( Division G)

As you can see at the bottom right of the table the average calculation is displaying 40.87%

Dgo1973_0-1677630475428.png

 

The Pie chart should show 40.87% for Division G, but instead shows 8.25 million 😖

 

Dgo1973_1-1677630749669.png

in fact every division  is calculated at the same average of 8.25M

which makes no sense

 

this is the formula behind the pie chart, need to find how to correct it

 

Sum of Standard Hours Efficiency weighted by Average of Standard Hours Efficiency per DIVI weighted by Average of Standard Hours Efficiency per DIVI =
VAR __CATEGORY_VALUES = VALUES('DBS WOPHDRS0'[DIVI])
RETURN
    DIVIDE(
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(
                [Sum of Standard Hours Efficiency weighted by Average of Standard Hours Efficiency per DIVI]
                    * AVERAGE('DBS WOPSEGS0'[Standard Hours Efficiency])
            )
        ),
        SUMX(
            KEEPFILTERS(__CATEGORY_VALUES),
            CALCULATE(AVERAGE('DBS WOPSEGS0'[Standard Hours Efficiency]))
        )
    )

 

 

Share the downoad link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Those link take me to a sign-in page.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That's the only link I know to share.

What other way there is to share a link when you have comapny license power bi ?

v-juanli-msft
Community Support
Community Support

Hi @jshaw

I want to take the average rating for each unique ID, and then the display the count of the average for each ID, in a pie chart, grouped by rating.

To get average rating for each unique ID, create a measure below

average rating for each unique ID = CALCULATE(AVERAGE(Sheet7[Rating]),ALLEXCEPT(Sheet7,Sheet7[ID]))

I wonder whether the average rating for each unique ID is the same with he count of the average for each ID, and if it is, when i add  the average rating for each unique ID to a pie chart and group by rating, it shows as below

24.png

show how many IDs have an average of each rating, So my pie chart would have 4 sections, and the values would add up to the distinct number of ID

Based on my understanding, it is just like below, is my understanding right?

distinct number of ID per rating = CALCULATE(DISTINCTCOUNT(Sheet7[ID]),ALLEXCEPT(Sheet7,Sheet7[Rating]))

22.png

Then you are able to filter by subject, then by group, and then by sub group.

 

Best Regards

Maggie

 

@v-juanli-msft @Greg_Deckler

 

This solution doesnt seem to be correct.  The pie chart, needs  to show the distinct count of each ID, based off  of the average rating for each ID.

 

 

This is the measure I am using to get the Average Rating for each ID.

 

Average of Rating average per ID = 
AVERAGEX(
VALUES('Sheet1'[ID]),
CALCULATE(AVERAGE('Sheet1'[Rating]))
)

But when I put it in a pie chart, it ends up not working correctly.  It shows 10% for ratign 1, 20% for rating 2, 30% for rating 3, and 40% for rating 4. 

Is that with the data that you presented originally? Can you post a screen shot or tell us what columns and measures you have in which fields in your pie chart?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler @v-juanli-msft

 

Here is a screenshot of what I have so far.

Capture.PNG

 

Here is the data set I am using.

IDSubjectGroupSub GroupRating
1MathAA-11
2MathAA-12
3MathAA-13
4MathAA-11
5MathAA-14
6MathAA-13
2ScienceBB-14
4ScienceBB-11
3ScienceBB-13
1ScienceBB-14
5ScienceBB-12
6ScienceBB-11
4ReadingAA-22
1ReadingAA-22
2ReadingAA-23
3ReadingAA-24
5ReadingAA-21
6ReadingAA-22
2MathLL-11
3MathLL-13
1MathLL-14
4MathLL-12
5MathLL-14
6MathLL-13

 

This is my measure I am using to calculate the average of Rating, based on the ID column.

 

Average of Rating average per ID = 
AVERAGEX(
	VALUES('Sheet1'[ID]),
	CALCULATE(AVERAGE('Sheet1'[Rating]))
)

 

 

This is the measure I am using to Count, each ID based off their average rating. (I have 4 of these measures, one for each rating)

 

CountOf1 = CALCULATE(DISTINCTCOUNT(Sheet1[ID]), FILTER(Sheet1,[Average of Rating average per ID] = 1))

 

Everything works as expected, except for the Pie chart.  The pie chart is showing the count of everything, and I need it to be grouped by unique IDs.  So in the Pie chart, I would expect the "CountOf3" section to show a value of 4.  And I would expect the "CountOf2" section, to show the value of 2.  ("CountOf1" and "CountOf4" sections would be 0, and not show in the pie chart)

jshaw
Frequent Visitor

Any other ideas?

Greg_Deckler
Super User
Super User

I don't think that I am entirely understanding what you are wanting to do here. What would your expected results be from the data given? Computing the average for each ID I get:

 

1 - 2.00

2 - 3.00

3 - 3.00

4 - 1.33

 

So, would you expect a pie chart where 2 would have a count of 1, 3 would have a count of 2 and 1.33 has a count of 1?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

My apologies for the lack of clarity, it is a little confusing.  But yes, I beleive what you described is correct.  However, the only condition is that when I filter, I want the calculated average to change based off the filter.  So for example,  if I filtered by math as the subject, then I would want the averages to re-compute based off only the data with the subject as math.  And then I would still expect that all the 4 sections ofthe pie chart would add up to the number of distinct IDs.

 

Hopefully that makes sense!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.