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
Anonymous
Not applicable

Formatting a bar graph

Hello all,

 

I have this sample data in Power BI:

 

UsersSalesmembersManagersCarsPhonesExpensespagers
10,2051,5005002,0002,0001,5031,500

 

and I am trying to create a chart like this:

 

Picture1.png

 

how can I recreate this in power bi? specifically with the category labels under the bars

 

thank you!!

 
 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

If that is how your source data is actually formatted, you need to unpivot all of those columns in Power Query and then the solution is trivial. Otherwise, create a disconnected table that lists your columns (categories). Use this as the Axis for your chart. Then create a measure that uses a SWITCH statement and based on the value in the axis, sum the right column as the return value for the measure.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
danextian
Super User
Super User

Hi @Anonymous ,

 

With the data you've posted, here's one way of  you can achieve your desired result:

  • Go the Query Editor and select all those columns.
  • Then right click and hit Unpivot Columns.
  • Unpivot will create two columns: Attribute and Value. Change Attribute to data type text and Value to Number.
  • Apply the changes.
  • Insert a bar chart. Add Attribute to Axis and Value to Value (make sure that the aggregation is sum).




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

is it possible to do the unpivot with DAX? 

Greg_Deckler
Community Champion
Community Champion

If that is how your source data is actually formatted, you need to unpivot all of those columns in Power Query and then the solution is trivial. Otherwise, create a disconnected table that lists your columns (categories). Use this as the Axis for your chart. Then create a measure that uses a SWITCH statement and based on the value in the axis, sum the right column as the return value for the measure.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

do you have a quick example of the switch statment to use in this case? I just created the table of all the categories for the axis 

Anonymous
Not applicable

can I unpivot using dax? I dont want to mess up all my other visuals

As a matter of fact, yes you can. I wrote a quick measure to do exactly that. https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832#M256.

 

However, that will not solve your problem since you still need something to put in the Axis. Sounds like you are headed down the disconnected table trick, this blog article demonstrates the technique. https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

thank you!! you are awesome!

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.