Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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.

 

 

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

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

7 Replies

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

    • Anonymous's avatar
      Anonymous
      Not applicable
      Ashish_Mathur You Sir, are a legend!!! OMG your solution worked! Thank you soooooooooo much!

      You’re a Power BI Expert!!! Best wishes!
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

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

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      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?

  • Mohammada's avatar
    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?

    and wanted to transform it into the following way:

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Super User

      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.