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

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
Super User
Super User

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.


@ 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!:
The Definitive Guide to Power Query (M)

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).









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


Proud to be a Super User!









"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
Super User
Super User

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.


@ 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!:
The Definitive Guide to Power Query (M)

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...


@ 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!:
The Definitive Guide to Power Query (M)

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

thank you!! you are awesome!

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.