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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
SloeMo
Frequent Visitor

Unpivotting multiple columns - Power query

Hi all, I have a sharepoint list with multiple columns in that I am tryting to pivot into a usable format. So far I have tried lots of steps which have all failed with the result of me creating duplcate queries and then appending to 1 table which is inefficient. I have tried following steps from other suggestions but cant seem to get it right

 

The data looks like this although there would be 22 Areas not just the 2 in my example below, each area has 4 columns attributed to them - Owner, Agreed, Date Agreed and commentary.

Programme Business Case NameBusiness Case OwnerArea 1 OwnerArea 1 AgreedArea 1 Date AgreedArea 1 CommentaryArea 2 OwnerArea 2 AgreedArea 2 DateArea 2 Commentary
Test ProgrammeLee TestLee MorganLee MorganYes30/06/2023text in hereLee MorgannullnullRandom text
Test Programme 2Lee Test 2Lee MorganLee MorgannullnullDifferent textLee Morgannullnullnull

 

What I am trying to achieve is something like the following format.

 

Programme Business Case NameBusiness Case OwnerAreaArea OwnerAgreedDate AgreedCommentary
Test ProgrammeLee TestLee MorganArea 1Lee MorganYes30/06/2023text in here
Test ProgrammeLee TestLee MorganArea 2Lee MorgannullnullRandom text
Test Programme 2Lee Test 2Lee MorganArea 1Lee MorgannullnullDifferent text
Test Programme 2Lee Test 2Lee MorganArea 2Lee Morgannullnullnull

 

Any help guidance is greatly appreciated.

 

Many thanks

Lee

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi

Unpivot columns, Split Attribute, Pivot

 

let
Source = YourSource,
Unpivot = Table.UnpivotOtherColumns(Source, {"Programme ", "Business Case Name", "Business Case Owner"}, "Attribute", "Value"),
#"Split Column" = Table.SplitColumn(Unpivot, "Attribute", Splitter.SplitTextByCharacterTransition({"0".."9"}, {" "}), {"Attribute.1", "Attribute.2"}),
Trim = Table.TransformColumns(#"Split Column",{{"Attribute.2", Text.Trim, type text}}),
Pivot = Table.Pivot(Trim, List.Distinct(Trim[Attribute.2]), "Attribute.2", "Value")
in
Pivot

Stéphane 

View solution in original post

3 REPLIES 3
SloeMo
Frequent Visitor

Thank you so much for this, has worked like a charm for the multiple columns.

slorin
Super User
Super User

Hi

Unpivot columns, Split Attribute, Pivot

 

let
Source = YourSource,
Unpivot = Table.UnpivotOtherColumns(Source, {"Programme ", "Business Case Name", "Business Case Owner"}, "Attribute", "Value"),
#"Split Column" = Table.SplitColumn(Unpivot, "Attribute", Splitter.SplitTextByCharacterTransition({"0".."9"}, {" "}), {"Attribute.1", "Attribute.2"}),
Trim = Table.TransformColumns(#"Split Column",{{"Attribute.2", Text.Trim, type text}}),
Pivot = Table.Pivot(Trim, List.Distinct(Trim[Attribute.2]), "Attribute.2", "Value")
in
Pivot

Stéphane 

HoussemDhahri
New Member

Hello , 

I have a scenario maybe it can help you :

  1. Duplicate your table.
  2. Remove all features related to Area 2 from the first table. Instead, add a new column called 'Area' and fill it with the value 'Area1' for all rows.
  3. Remove all features related to Area 1 from the second table. Instead, add a new column called 'Area' and fill it with the value 'Area2' for all rows.
  4. Append both tables together and rename the headers as desired.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.