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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Transpose excel data into columns in Power BI

Hi !

I wanted to transpose the excel data in Power BI so I get the Item, year , months , other data in individual columns, which I am struggling with now.

I want to show it like in the columns below.

 

Item                                                   Year   Month Data

Projects Completed/month               2019   Oct      0

Projects Completed/month               2019   Nov     0

Projects Completed/month               2019   Dec     1

Projects Is completed/month            2019   Oct      0

Projects Is completed/month            2019   Nov     0

Projects Is completed/month            2019   Dec     11

Total Projects Is Completed              2019   Oct      0

Total Projects Is Completed              2019   Nov     0

Total Projects Is Completed              2019   Dec     11

Projects Completed/month               2019   Oct      0

Projects Completed/month               2019   Nov     0

Projects Completed/month               2019   Dec     0

Projects Is completed/month            2019   Oct      0

Projects Is completed/month            2019   Nov     0

Projects Is completed/month            2019   Dec     0

Total Projects Is Completed              2019   Oct      11

Total Projects Is Completed              2019   Nov     11

Total Projects Is Completed              2019   Dec     11

 

and so on.....

There are three sets on data on the table below and I want it all to be in columns so its appropriate when building the report based on the Year/month data

 2019
 OctNovDec
Projects Completed/month001
Projects Is completed/month0011
Total Projects Is Completed0011
Total Projects353  
Total Projects Is27039  
 2019
 OctNovDec
ETH - High3688
Cummulative ETH - low71188
Total Low ETH9121
 2019
 OctNovDec
ETH - low5833
Cummulative ETH - low9733
Total Low ETH651

Help will be greatly appreciated.

2 ACCEPTED SOLUTIONS
ahmedoye
Resolver III
Resolver III

@Anonymous , when your data has the two beginning rows that you will like to bring as separate columns, (Kind of like two heading rows), you should do the following:

  1. Transpose the Table: This will bring the two heading rows into columns but will make the previously good column go into rows with the items on the first row. Not to worry, apply the next steps
  2. Go to Transform Tab and Use First Row as Header: This will make the items on the first row become the heading
  3. Select the two new columns, right click and select Unpivot Other Columns: This will now make you have a new column with the items in the headings becoming the new column, and the values right in front of them as a new column.

You may need to do a little bit of cleanup here and there afterwards.

 

I hope this works for you, if it does, kindly mark as solution to enable other people benefit from this.

View solution in original post

@ahmedoye this is a great solution!

 

See below for the M query:

let
Source = Excel.Workbook(File.Contents("C:\Users\bfernandez1\Desktop\Temp\Book1.xlsx"), null, true),
Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet2_Sheet,{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}}),
#"Transposed Table" = Table.Transpose(#"Changed Type"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", Int64.Type}, {"Column2", type text}, {"EWP's completed per month", Int64.Type}, {"Initial Isometrics completed per month", Int64.Type}, {"Initial Total Isometrics", Int64.Type}, {"Initial total EWP's", Int64.Type}, {"Total Isometrics", Int64.Type}, {"Column8", type any}, {"Column9", Int64.Type}, {"Column10", type text}, {"EWP's completed per month_1", Int64.Type}, {"Isometrics completed per month", Int64.Type}, {"Total Isometrics_2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Column1", "Column2"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Attribute] <> "Column10" and [Attribute] <> "Column9")),
#"Filled Down" = Table.FillDown(#"Filtered Rows",{"Column1"})
#"Replaced Value" = Table.ReplaceValue(#"Filled Down","_1","",Replacer.ReplaceText,{"Attribute"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","_2","",Replacer.ReplaceText,{"Attribute"})
in
#"Replaced Value1"

 Of course, change where there are strikethroughs with your own data.

View solution in original post

12 REPLIES 12
ahmedoye
Resolver III
Resolver III

@Anonymous , when your data has the two beginning rows that you will like to bring as separate columns, (Kind of like two heading rows), you should do the following:

  1. Transpose the Table: This will bring the two heading rows into columns but will make the previously good column go into rows with the items on the first row. Not to worry, apply the next steps
  2. Go to Transform Tab and Use First Row as Header: This will make the items on the first row become the heading
  3. Select the two new columns, right click and select Unpivot Other Columns: This will now make you have a new column with the items in the headings becoming the new column, and the values right in front of them as a new column.

You may need to do a little bit of cleanup here and there afterwards.

 

I hope this works for you, if it does, kindly mark as solution to enable other people benefit from this.

@ahmedoye this is a great solution!

 

See below for the M query:

let
Source = Excel.Workbook(File.Contents("C:\Users\bfernandez1\Desktop\Temp\Book1.xlsx"), null, true),
Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet2_Sheet,{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}}),
#"Transposed Table" = Table.Transpose(#"Changed Type"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", Int64.Type}, {"Column2", type text}, {"EWP's completed per month", Int64.Type}, {"Initial Isometrics completed per month", Int64.Type}, {"Initial Total Isometrics", Int64.Type}, {"Initial total EWP's", Int64.Type}, {"Total Isometrics", Int64.Type}, {"Column8", type any}, {"Column9", Int64.Type}, {"Column10", type text}, {"EWP's completed per month_1", Int64.Type}, {"Isometrics completed per month", Int64.Type}, {"Total Isometrics_2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Column1", "Column2"}, "Attribute", "Value"),
#"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Attribute] <> "Column10" and [Attribute] <> "Column9")),
#"Filled Down" = Table.FillDown(#"Filtered Rows",{"Column1"})
#"Replaced Value" = Table.ReplaceValue(#"Filled Down","_1","",Replacer.ReplaceText,{"Attribute"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","_2","",Replacer.ReplaceText,{"Attribute"})
in
#"Replaced Value1"

 Of course, change where there are strikethroughs with your own data.

bfernandez
Resolver II
Resolver II

Okay so if your goal is to get the data looking like you'd like in the table you posted, you can take another approach.

Keep the data as it is coming in from the source and do your editing in Power Query using the following steps:

 

Merge Month and Year:

merge.png

MonthYear.png

 

Then Parse the MonthYear to get the start date of each MonthYear:

Parse.png

SoM.png

 

Then after Closing and Applying the steps, create a Matrix visual and populate it with the data as shown below:

Matrix.png

Anonymous
Not applicable

Sorry if I had confused you in my original post, the table posted there was the data from the data source and the list I mentioned was how it should look like.

It should llook like the following in Power BI so I can create reports :

Item                                         Year   Month Data

Projects Is completed/month            2019   Nov     0

Projects Is completed/month            2019   Dec     11

Total Projects Is Completed              2019   Oct      0

Total Projects Is Completed              2019   Nov     0

Anonymous
Not applicable

When data comes as is from excel it looks like this, the months and years are in rows , how do I make it into the format you have in your first screen shot and then follow through.

Capture2.PNG

This data seems very messy the way that it is presented or I am not getting the full picture. 

 

It is showing certain categories that are not grouped as they should be or I'm not seeing the information.

For example, there are multiple "Isometrics completed per month with different values under the same Oct 2019 column.

Can you elaborate a little bit more or give a bigger picture of the data you are giving?

amitchandak
Super User
Super User
bfernandez
Resolver II
Resolver II

You can transpose data using the Transpose feature within Power Query.

 

You can fin it on the Transform tab, in the Table section.

 

transpose.png

Anonymous
Not applicable

My Data now looks something like this 

 

I cannot see anything attached to your reply, can you attempt to send the screenshots again?

Anonymous
Not applicable

Capture.PNG

 

Anonymous
Not applicable

 Thanks bfernandez, I am using the transpose function but its not arranging as I want. Tried several ways but its not re-arranging it the way I want it to be unfortunately.

 

Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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