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
afaherty
Helper V
Helper V

Attempting to create a histogram (distribution) bar chart based on a measure

Hello,

I am attempting to create a histogram (distribution) bar chart based on a measure and am failing miserably. I wasn't sure if this question should go here or in the DAX forum.

 

Here is an example of my student test data:

 

Student IDTestSubtestPointsMax
1MathFractions57
1MathEquations77
1MathDecimals36
1EnglishParts of speech812
1EnglishDiagramming1113
1EnglishConjugations910

 

I have a measure called Score which gives each student's Math score and English score (depending on which is chosen via slicer): 

DIVIDE(SUM('Test Scores'[Points]),SUM('Test Scores'[Max]))

 

So in this case it would show in a matrix that student 1 got 15/20 = 75% on math and 28/35 = 80% on English.

 

The problem is that I need to see the class's distribution of scores, like for example this chart, which shows how many students scored each score:

 

afaherty_0-1724872057958.png

 

However, this is not possible with a measure. Can anyone offer any solutions? Thank you.

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @afaherty 

 

please check if this accomodate your need.

 

first, i assumed the percent only limited to 'Test' only. also i added another student ID because i assumed you will have plenty of different student id.

 

1. create a measure as your measure above.

Sum of Point = DIVIDE(SUM('Table'[Points]),SUM('Table'[Max]))
 
2. create a calculated column with following DAX as you need for your x-axis value.
Percent = 
CALCULATE(
    [Sum of Point],
    FILTER(
        'Table',
        'Table'[Test]=EARLIER('Table'[Test])&&
        'Table'[Student ID]=EARLIER('Table'[Student ID])
    )
)
Irwan_0-1724891591427.png

 

3. plot the column and student ID in bar chart (dont forget to change Y-axis into count distinct)

Irwan_1-1724891712466.png

 

4. to make similar to your example graphic, then change minimum and maximum value so it will show 0%-100% and invert range to make 100% on the left.

Irwan_3-1724891937828.png

 

Hope this will help.

Thank you.

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBi file.


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

hello @afaherty 

 

please check if this accomodate your need.

 

first, i assumed the percent only limited to 'Test' only. also i added another student ID because i assumed you will have plenty of different student id.

 

1. create a measure as your measure above.

Sum of Point = DIVIDE(SUM('Table'[Points]),SUM('Table'[Max]))
 
2. create a calculated column with following DAX as you need for your x-axis value.
Percent = 
CALCULATE(
    [Sum of Point],
    FILTER(
        'Table',
        'Table'[Test]=EARLIER('Table'[Test])&&
        'Table'[Student ID]=EARLIER('Table'[Student ID])
    )
)
Irwan_0-1724891591427.png

 

3. plot the column and student ID in bar chart (dont forget to change Y-axis into count distinct)

Irwan_1-1724891712466.png

 

4. to make similar to your example graphic, then change minimum and maximum value so it will show 0%-100% and invert range to make 100% on the left.

Irwan_3-1724891937828.png

 

Hope this will help.

Thank you.

Beautiful! Thank you so much, I really appreciate it!!

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.