Forum Discussion
bman6074
6 years agoHelper I
Transpose Table
Hi, Is there a way to transpose/pivot this (Current picture) table to (Transpose picture) So each name is across the top and the usage risk scores listed below? Then ultimatly I want to take highes...
- 6 years ago
Hi bman6074 ,
We can transpose it by using "Transform" - "Povit Column" in Power Query Editor, then select maximum as aggreration function:
Or we can append this step in your queries
let Source = Sql.Databases("database.power bi"), Powerbi= Source{[Name="powerbi"]}[Data], snow_AllRelationshipsKeyTable = powerbi{[Schema="snow",Item="AllRelationshipsKeyTable"]}[Data], #"Changed Type" = Table.TransformColumnTypes(snow_AllRelationshipsKeyTable,{{"EOL", type date}, {"EOSL", type date}, {"LCS_GA", type date}}), #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Name", "Usage_Risk_Score"}), PivotStep = Table.Pivot(#"Removed Other Columns", List.Distinct(#"Changed Type"[Name]), "Name", "Usage_Risk_Score", List.Max) in PivotStep
By the way, PBIX file as attached.
Best regards, - 6 years ago
Hi bman6074 ,
Please try to change the data type of Usage_Risk_Score column to whole number before unpivot,
Or use the following query:
let Source = Sql.Databases("database.power bi"), Powerbi= Source{[Name="powerbi"]}[Data], snow_AllRelationshipsKeyTable = powerbi{[Schema="snow",Item="AllRelationshipsKeyTable"]}[Data], #"Changed Type" = Table.TransformColumnTypes(snow_AllRelationshipsKeyTable,{{"EOL", type date}, {"EOSL", type date}, {"LCS_GA", type date}}), #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Name", "Usage_Risk_Score"}), ChangeType = Table.TransformColumnTypes(#"Removed Other Columns",{{"Name", type text}, {"Usage_Risk_Score", Int64.Type}}), PivotStep = Table.Pivot(#"ChangeType", List.Distinct(#"Changed Type"[Name]), "Name", "Usage_Risk_Score", List.Max) in PivotStep
Best regards,
amitchandak
6 years agoSuper User