Skip to main content
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

Frequent Visitor

Pivot Unpivot Multiple values

Hi friends - One of my data sources is a SharePoint list (created from SP forms) and is in the format below:

Project TitleProject ManagerRisk Name 1Risk Category 1Risk Status 1Risk Priority 1Risk Name 2Risk Category 2Risk Status 2Risk Priority 2Risk Name 3Risk Category 3Risk Status 3Risk Priority 3


I need to modify this list in to the format below, so I can append this dataset to other datasets:

Project Title Project ManagerRisk NameRisk CategoryRisk StatusRisk Priority


How can I achieve this using Power Query or any other way in Power BI? I tried multiple ways (unpivoting, removing duplicates, pivoting) but not able to achieve desired output. Please help!




Super User
Super User

it's the #"Removed Columns" line.  The pivot needs that column to identify unique rows.

So remove that step.  You might want to filter out blank values from the Value column also.

Then do the pivot.

If you need to filter out rows after that then you can identify them at that stage.

View solution in original post

Super User
Super User

If you don't filter out blank values (my suggestion in previous post), then you should still see Project4 rows after pivot 

Thank you!

Super User
Super User

it's the #"Removed Columns" line.  The pivot needs that column to identify unique rows.

So remove that step.  You might want to filter out blank values from the Value column also.

Then do the pivot.

If you need to filter out rows after that then you can identify them at that stage.

Life Saver! That worked! Thank you so much! One small issue is there is Porject4 which has 0 risks and is getting removed automatically when I unpivot, how can I keep the projects that have 0 risks (risk information is not populated for those)?

Super User
Super User

Are you using sample data or the real data?

Post the 'Advanced Editor' code and I'll have a look

Thank you so much taking time to help me. I have modified the input file to reflect more acccurate situation: 

Project TitleProject ManagerTotal RisksRisk Name 1Risk Priority 1Risk Impact 1Risk Status 1Risk Name 2Risk Priority 2Risk Impact 2Risk Status 2Risk Name 3Risk Priority 3Risk Impact 3Risk Status 3
Project1PM13Risk1HighFinanceClosedRisk2MediumScheduleRealizedRisk3Very HighScopeCancelled
Project3PM32RiskP3Vey HighScopeRealizedRiskP32LowFinanceOpen    


Here's the erorr I'm getting: 



Here's the M code:

Source = Excel.Workbook(File.Contents("C:\Users\radarla\Documents\Risks.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Project Title", type text}, {"Project Manager", type text}, {"Total Risks", Int64.Type}, {"Risk Name 1", type text}, {"Risk Priority 1", type text}, {"Risk Impact 1", type text}, {"Risk Status 1", type text}, {"Risk Name 2", type text}, {"Risk Priority 2", type text}, {"Risk Impact 2", type text}, {"Risk Status 2", type text}, {"Risk Name 3", type text}, {"Risk Priority 3", type text}, {"Risk Impact 3", type text}, {"Risk Status 3", type text}}),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"Risk Name 1", "Risk Priority 1", "Risk Impact 1", "Risk Status 1", "Risk Name 2", "Risk Priority 2", "Risk Impact 2", "Risk Status 2", "Risk Name 3", "Risk Priority 3", "Risk Impact 3", "Risk Status 3"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Only Selected Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Attribute.2"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute.1]), "Attribute.1", "Value")
#"Pivoted Column"


Super User
Super User

There are definitely examples of this in this forum.

The basic algorithm is :

Select the first two columns->Unpivot other columns

Split the Attribute Column to make 2 columns. The left one (call it C1) will be a limited set of values which will be the new column headings.

Pivot the C1 column using Values column in Values and "Don't Aggregate" in the Advanced Section.

For sample data as provided that will work.  The real data may not have numbers after the words so may be a little more complex.


Good luck

Thank you for replying. I tried all those steps, when I try to pivot as the last step I'm getting Expression Error: There were too many elements in th enumeration to complete the operation. Details: [List]. 

Which I understand as there are multiple values for the same field which should be treated as a duplicate (for all other values except the currrent one) record as shown in the example above and create a new row, but that's not happening. Any suggestions on how to work around this error?

Helpful resources

Europe Fabric Conference

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.


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.

Top Solution Authors
Top Kudoed Authors