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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sharad-vm
New Member

Need help with a DAX calculation/graph

Hello,

 

I am relatively new to DAX and I seem to have a unique requirement. 

 

Here's some sample data - 

IDScore
11
13
24
22

 

Ideally, I'm looking for a pie chart broken down by the score and counting the number of IDs whose average score falls into that score bucket.
For example, I want the result to look like this - 

ScoreCount of IDs
10
21
31
40

 

Explanation - Since ID 1 has scores of 1 and 3, their average is 2 and will be counted in the 2 score bucket. 
Since ID 2 has scores of 4 and 2, their average is 3 and will be counted in the 3 score bucket. 

 

How can I achieve this?

3 REPLIES 3
isjoycewang
Solution Supplier
Solution Supplier

Hi @sharad-vm ,

 

Please refer to attached file for details.

1. Create [Avg. Score] column

Avg Score = 
VAR _ID = [ID]
RETURN
CALCULATE( AVERAGE('Table'[Score]), FILTER(ALL('Table'), 'Table'[ID] = _ID))

 

2. Create [Count] measure

Count = 
VAR _Score = SELECTEDVALUE('Table'[Score])
VAR _Count = CALCULATE(DISTINCTCOUNT('Table'[ID]), FILTER(ALL('Table'), 'Table'[Avg Score] = _Score))

RETURN _Count

 

isjoycewang_0-1731637284641.png

 

Best Regards,

Joyce

 

Thanks for your response, @isjoycewang !

This works only if we don't have other fields in the table that we use to filter the page. 

Calculated column doesn't get calculated on the fly as we change the filters. 
I should have made that clear in the original question itself. Apologies. 

There are a few more fields in the table that will be used as a filter. 

Anonymous
Not applicable

Thanks for the reply from isjoycewang , please allow me to provide another insight:

Hi, @sharad-vm 

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1731918807067.png

2.I then created the following calculated table to extract the score values independently, ensuring they are not directly affected by the slicer:

Table 2 = SUMMARIZE('Table','Table'[Score])

3.Additionally, I created the following measures:

MEASURE = 
VAR aa =
    DISTINCT (
        SUMMARIZE (
            'Table',
            'Table'[ID],
            "avg",
                ROUND (
                    CALCULATE (
                        AVERAGE ( 'Table'[Score] ),
                        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) )
                    ),
                    0
                )
        )
    )
VAR ct =
    COUNTX ( FILTER ( aa, [avg] = MAX ( 'Table 2'[Score] ) ), 'Table'[ID] )
RETURN
    IF ( ISBLANK ( ct ), 0, ct )

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1731918879816.png

 

 

vlinyulumsft_2-1731918879816.png

vlinyulumsft_3-1731918896890.png

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.