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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply

Convert excel matrix table to flattened table

The Excel tables that I receive for import into Power BI always have data arranged as a matrix.

 

Where is a good place that I can learn how to convert a matrix into a flattened table?

 

I've found this very difficult to learn.

 

Transpose, Pivot, Unpivot just seem to mess up the arrangement that I'm seeking ie one column per common variable.

 

Here's an example of the type of data that I receive:

Columns C to H have subcategories.Columns C to H have subcategories.

 

 

I have an active question about how to convert this to a flattened table if you wish to contribute.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Instead of having 2 rows for every column, have just one.  So row 2 should have Year, DHB, Maori - Enrolled, Maori - Populaiton etc.  Once that is done, take the data to the Query Editor, right click on the first 2 columns and select Unpivot other columns.  You may then split the attribute column by the - delimiter.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Mohammada
Regular Visitor

Hi,

 

I have a similar query with the data but wanted to automate the process as I receive daily data which needs to be updated. How can I query this?

ec production plan.png

and wanted to transform it into the following way:output.png

Hi,

Your input data is in very bad shape.  It may take a lot of effort to get it in your desired format.  It may not be an easy task.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

Instead of having 2 rows for every column, have just one.  So row 2 should have Year, DHB, Maori - Enrolled, Maori - Populaiton etc.  Once that is done, take the data to the Query Editor, right click on the first 2 columns and select Unpivot other columns.  You may then split the attribute column by the - delimiter.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur You Sir, are a legend!!! OMG your solution worked! Thank you soooooooooo much!

You’re a Power BI Expert!!! Best wishes!

You are most welcome.  I am just a learner like you.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

In edit query, select first two columns and then right click and then "unpivot other columns"

 

you will get attribute and value, attribute will be your category c to h and value.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for your reply @parry2k

 

When I pasted the image above I'd left out row 1. I've now pasted the correct image.

 

Note that rows C-D, E-F, and G-H are categories, and nested below those population groups are the variables Enrolled, Population.

 

So I'd like to end up with a flattened table that has the columns:

Year - DHB - Group - Enrolled - Population

 

Group would be the columns I mentioned above ie Maori, Pacific, Other.

 

Any advice on how I'd go about this?

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.