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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

convert columns to rows for a bar chart

Hi everyone,

 

I have a data set in the following format:

 

Main Equipment

Sub Equipment

Sub-Sub Equipment

E1

S1

SS1

E1

S1

SS1

E2

S2

SS2

E2

S3

SS4

 

I want to convert it to the following format and make a bar chart for it.

Equipment Level

Count

Main Equipment

2

Sub Equipment

3

Sub-Sub Equipment

3

 

If I use matrix and transpose the rows and then, use count(distinct), I can make the following plot. The issue is that it doesn't show the name of equipment level on X-xis:

 

Bar chart based on matrixBar chart based on matrix

 

 

 

 

 

 

 

 

 

 

Following imaginary output is what I look for:

 

Desired barchartDesired barchart

 

Please consider that there are other visuals build based on this data set and I can't change the format of the data set in the Power Query.

 

 

Thanks.

 

 

 

1 ACCEPTED SOLUTION
Thejeswar
Community Champion
Community Champion

Hi @Anonymous ,

You can just duplicate your data source and transform the data like how @HashamNiaz  said.

 

Then use this new dataset for your visual.

As you are dupicating the dataset, you will have it dynamic as well as you don't have to hard code.

As the dataset is the duplicte of the original dataset, once the orginal dataset updates, this too gets refreshed with the latest data

 

Hope this helps!!

View solution in original post

5 REPLIES 5
Thejeswar
Community Champion
Community Champion

Hi @Anonymous ,

You can just duplicate your data source and transform the data like how @HashamNiaz  said.

 

Then use this new dataset for your visual.

As you are dupicating the dataset, you will have it dynamic as well as you don't have to hard code.

As the dataset is the duplicte of the original dataset, once the orginal dataset updates, this too gets refreshed with the latest data

 

Hope this helps!!

Anonymous
Not applicable

Hi @Jihwan_Kim 

I can't do it. It's a sort of hard coding:)

We can't create one table per each request as these tables will be added to our model and it's not a best practice to do so. More importantly, I want to use this visualisation as the first level of a drill-down scenario, so it should be related to other dimensions which I have. 

 

 

HashamNiaz
Solution Sage
Solution Sage

Hi @Anonymous !

You can simply go to Power Query editor (Transform Data), select the all 3 column and perform Unpivot Transformation.

 

UnpivotUnpivotPivotPivot

 

Relabel the column name, now in your report simply plot the chart against your category & distinct count.

 

ChartChart

 

Regards,

Hasham

Anonymous
Not applicable

@HashamNiaz 

Thanks for your reply but I can't reshape the data set format for this request. There are other visuals using this data set in the original format.

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I assume you can manually create one more axis table inside Power BI like below.

Please check the below picture and the sample pbix file's link down below.

all measures are in the sample pbix file.

In this case, I used explicit measures, not implicit measures.

 

Picture1.png

 

https://www.dropbox.com/s/3nzqvl9ggjagz96/tooba.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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