Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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:

 

 

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

 

thank you!!

 
 

 

 

 

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

7 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    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.

  • 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).
    • Anonymous's avatar
      Anonymous
      Not applicable

      is it possible to do the unpivot with DAX?