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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
shairado
Frequent Visitor

How to Pivot multiple two column with values to a Flat format

Hi,

 

I am trying to use Power-Query to Pivot Data of multiple columns, but only able to get 1 column pivoitzed.

 

I have a table, where each 'Proj#' has 3 milestones, and each milestone has 2 columns with properties I want to flat - 'Value' and 'Date'.

 

This is the format of the original table:

Orig Table.PNG

 

 

 

 

And this is the desired result, where each 'Proj#' has 1 row, and 6 columns:

Required Table.PNG

 

Any help would be great.

 

Thanks,

Shai

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Proj#", "Milestones"}, "Attribute", "Value.1"),
    #"Merged Columns" = Table.CombineColumns(#"Unpivoted Other Columns",{"Milestones", "Attribute"},Combiner.CombineTextByDelimiter(" - ", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value.1")
in
    #"Pivoted Column"

View solution in original post

2 REPLIES 2
shairado
Frequent Visitor

@AlienSx  thank you, worked great.

AlienSx
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Proj#", "Milestones"}, "Attribute", "Value.1"),
    #"Merged Columns" = Table.CombineColumns(#"Unpivoted Other Columns",{"Milestones", "Attribute"},Combiner.CombineTextByDelimiter(" - ", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value.1")
in
    #"Pivoted Column"

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors