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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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