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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Unpivot columns

Hello everyone, i am trying to unpivot data. see below image. this is my data1.PNGAnd expected result is

2.PNG

 

can anyone help me

1 ACCEPTED SOLUTION
Anonymous
Not applicable

i have resolver by my self. using custom code, i have achive this.

 

let
Source = Excel.Workbook(File.Contents("....test pivot.xlsx"), null, true),
Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data],
#"Added Custom" = Table.AddColumn(Table1_Table, "Custom", each 
#table( 
type table [Module=text, Date=number, Time=text, Time1=text],
{
{ "Mod", [Mod], "Time", [Time] },
{ "abc", [abc], "Time2", [Time2] },
{ "bsd", [bsd], "Time3", [Time3] },
{ "sdf", [sdf], "Time4", [Time4] },
{ "aert", [aert], "Time5", [Time5] },
{ "hwh", [hwh], "Time6", [Time6] },
{ "qgqsdg", [qgqsdg], "Time7", [Time7] },
{ "eyyr", [eyyr], "Time8", [Time8] },
{ "qsxddt", [qsxddt], "Time9", [Time9] },
{ "jkhktr", [jkhktr], "Time10", [Time10] }
}
), type table
),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Mod", "Time", "abc", "Time2", "bsd", "Time3", "sdf", "Time4", "aert", "Time5", "hwh", "Time6", "qgqsdg", "Time7", "eyyr", "Time8", "qsxddt", "Time9", "jkhktr", "Time10"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Module", "Date", "Time", "Time1"}, {"Module", "Date", "Time", "Time1"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each [Date] <> null and [Date] <> ""),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Date", type date}})
in
#"Changed Type"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

i have resolver by my self. using custom code, i have achive this.

 

let
Source = Excel.Workbook(File.Contents("....test pivot.xlsx"), null, true),
Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data],
#"Added Custom" = Table.AddColumn(Table1_Table, "Custom", each 
#table( 
type table [Module=text, Date=number, Time=text, Time1=text],
{
{ "Mod", [Mod], "Time", [Time] },
{ "abc", [abc], "Time2", [Time2] },
{ "bsd", [bsd], "Time3", [Time3] },
{ "sdf", [sdf], "Time4", [Time4] },
{ "aert", [aert], "Time5", [Time5] },
{ "hwh", [hwh], "Time6", [Time6] },
{ "qgqsdg", [qgqsdg], "Time7", [Time7] },
{ "eyyr", [eyyr], "Time8", [Time8] },
{ "qsxddt", [qsxddt], "Time9", [Time9] },
{ "jkhktr", [jkhktr], "Time10", [Time10] }
}
), type table
),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Mod", "Time", "abc", "Time2", "bsd", "Time3", "sdf", "Time4", "aert", "Time5", "hwh", "Time6", "qgqsdg", "Time7", "eyyr", "Time8", "qsxddt", "Time9", "jkhktr", "Time10"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Module", "Date", "Time", "Time1"}, {"Module", "Date", "Time", "Time1"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each [Date] <> null and [Date] <> ""),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Date", type date}})
in
#"Changed Type"
AlB
Community Champion
Community Champion

Hi @Anonymous 

Can you please paste a sample of the table (including all relevant columns) here in text-tabular format, so that it can be copied and worked on (instead of on a screen capture)

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs

Cheers 

SU18_powerbi_badge

 

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors