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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Histogram by Percentage

I have to recreate the following graph from excel in Power BI 

Original Excel GraphOriginal Excel Graph

My data looks like the following:

My DataMy Data

As you can see, I need to split up the data into blocks (e.g. 0-100, 100-200...) and then calculate the percentage of the values in each block and then graph that. I am new to Power BI and have tried playing around with it, but cannot work out how to create this graph. Thanks in advance.

1 ACCEPTED SOLUTION

Hi @Anonymous 

Enter data to create a new table

Capture5.JPG

Capture6.JPG

Create calculated columns

bucket = SWITCH(TRUE(),[value]>=0&&[value]<1000,"1000",[value]>=1000&&[value]<2000,"2000",[value]>=2000&&[value]<3000,"3000")

Capture7.JPG

Create measures

frequency = CALCULATE(COUNT('Table'[value]),ALLEXCEPT('x table','x table'[x_values]))

percentage = [frequency]/CALCULATE(COUNT('Table'[value]),ALL('Table'))

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User
Anonymous
Not applicable

Perfect! Yep that has allowed me to create a histogram from my data, thank you. However, any idea how to change the y axis from frequency to percentage?

Hi @Anonymous 

Create a calcualated column

 

bucket =
SWITCH (
    TRUE (),
    [value] >= 0
        && [value] < 100, "0~100",
    [value] >= 100
        && [value] < 200, "100~200",
    [value] >= 200
        && [value] < 300, "200~300",
    [value] >= 300
        && [value] < 400, "300~400",
    [value] >= 400
        && [value] < 500, "400~500"
)

 

Create measures

 

frequency = CALCULATE(COUNT('Table'[value]),ALLEXCEPT('Table','Table'[bucket]))

percentage = [frequency]/CALCULATE(COUNT('Table'[value]),ALL('Table'))

 

Capture13.JPG

Anonymous
Not applicable

Hey, thanks for that! Is there anyway to have it so the x axis displays just 1000, 2000, 3000 etc. and not the 0~100, 100~200?

Hi @Anonymous 

Enter data to create a new table

Capture5.JPG

Capture6.JPG

Create calculated columns

bucket = SWITCH(TRUE(),[value]>=0&&[value]<1000,"1000",[value]>=1000&&[value]<2000,"2000",[value]>=2000&&[value]<3000,"3000")

Capture7.JPG

Create measures

frequency = CALCULATE(COUNT('Table'[value]),ALLEXCEPT('x table','x table'[x_values]))

percentage = [frequency]/CALCULATE(COUNT('Table'[value]),ALL('Table'))

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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