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
Kilm
New Member

How to make PBI use an Excel with merged column headers

Hi folks,

 

I've spent four hours trying various solutions and guides but just cannot figure this out.

 

I have an Excel which has four column headers, let's say they are One, Two, Three and Four. These are merged over two columns each.

 

Beneath each merged column header is the two columns, each with their own header.

 

So:

 

[One]

First | Second

 

And so on

 

When I load this in and try to put it in a bar chart, it doesn't work and PBI has difficulty reading it. I've tried unpivoting and merging in query but I just can't figure it out

 

I want PBI to show me the four merged headers and then sub headers so I can put them in a bar chart.

 

Any advice is greatly appreciated.

 

5 REPLIES 5
jgeddes
Super User
Super User

If I understand correctly you have data somewhat like...

jgeddes_0-1698763550842.png

And you want something like...

jgeddes_1-1698763585033.png

Assuming the merged first row loads in with null in every other column (as below) you could do the following...

jgeddes_2-1698763848509.png

Transpose the whole table...
Fill down the first column to remove the null values...

jgeddes_3-1698763919944.png 

jgeddes_4-1698763932058.png

merge the first two columns together using a delimiter that does not exist in either column...

transpose the table back and promote the first row as headers...

jgeddes_5-1698764003364.png

unpivot the whole table and then split the first column by the delimiter you chose in the merge step...

jgeddes_6-1698764076962.png

 





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

Proud to be a Super User!





Kilm0
Frequent Visitor

Thank you for your help and time with this. I've managed to get on via the desktop so I can share a screenshot of the example dataset.

 

Kilm0_0-1698837808821.png

 

I apologise for explaining it poorly!

I've tried your method as outlined, but with the query looking like this:

Kilm0_1-1698837973495.png

 

when I transpose the whole table it looks like this:

Kilm0_2-1698838035947.png

 

and if I do the fill down, then it replaces the nulls with numbers, which I guess would skew the data?

I follow the rest of your steps but it all goes off the rails a bit and ends up nothing like yours.

Again I apologise for the poor description at the start and the time you're giving to this!

 

No worries. Here is a modified solution for you to try...
Load in your Excel file but make sure the headers are not promoted so you end up with something like...

jgeddes_0-1698843534626.png

Transpose the whole table... 

jgeddes_1-1698843579041.png

Fill down the first column and merge it with the second column. (Again, use a delimiter that is not in your string values.) Then promote the headers as first row.

jgeddes_3-1698843702986.png

Select the first column and then choose 'Unpivot Other Columns'...

jgeddes_5-1698843841086.png

Split the first column by delimiter, rename the columns to what you want and set the correct data types and you should be good to go...

jgeddes_6-1698843913367.png

 

 





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

Proud to be a Super User!





Kilm0
Frequent Visitor

Thank you again, I'm very conscious of the fact you've turned into my one-to-one PBI mentor on this!!

 

So I start with my data, and I go to 'User Headers as First Row' to ensure they're not promoted. I end up with this:

 

Kilm0_0-1698919449828.png

 

I transpose to this:

Kilm0_1-1698919493047.png

 

However I saw that you have nulls and I don't, but I did some further reading and figured that out, so I replaced the values to null to mirror you:

 

Kilm0_2-1698919735403.png

 

I then fill down successfully (as it wasn't before, and I read that it was because of the null thing) and have this:

Kilm0_3-1698919849499.png

 

Then I promote first row to headers and get:

Kilm0_4-1698919993465.png

 

and from there on everything you've said works fine.

 

I've got the data into PBI on a bar chart now, but I can't seem to get it looking like yours, where it has the merged header then the two columns for pass and fail showing. It either shows one or the other depending on what's on top on the Axis field.

 

Thank you so much again for your time with this. I'm sure there's an obvious answer staring me in the face with this!

Glad you were able to get the results you needed. Power Query is incredibly useful in transforming 'lemon' spreadsheets into 'lemonade'. 
For your chart, I set up the fields as follows...

jgeddes_0-1698929806225.png

which gets...

jgeddes_1-1698929825546.png

click on the 'Expand all down one level...' icon to get...

jgeddes_2-1698929877315.png

jgeddes_3-1698929889833.png

Cheers.

 





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

Proud to be a Super User!





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.