Forum Discussion
Anonymous
2 years agoNot applicable
Transpose Challenge
Hi Community, I'm trying to solve a transpose issue, if you look at the snapshot below, an employee has two records. One record is their current performance score and the next record is their previ...
- 2 years ago
pivot RatingDate
Anonymous
2 years agoNot applicable
Hi Anonymous ,
Like this?
Advanced editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZcvBCcAwDATBXu5tge4kpRmj/ttIjMEQ/NjXsHOC7plPJQa0ctEoC6LHT2Orbq1P8ihNl9bWWK+E7hc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PersonID = _t, PerformanceRating = _t, RatingDate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"PersonID", Int64.Type}, {"PerformanceRating", Int64.Type}, {"RatingDate", type date}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"PersonID", Order.Ascending}, {"RatingDate", Order.Ascending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"PersonID"}, {{"Data", each _, type table [PersonID=nullable number, PerformanceRating=nullable number, RatingDate=nullable date]}}),
Custom1 = Table.TransformColumns(#"Grouped Rows",{"Data", each Table.Pivot(Table.TransformColumnTypes(_, {{"RatingDate", type text}}, "en-US"),List.Distinct(Table.TransformColumnTypes(_, {{"RatingDate", type text}}, "en-US")[RatingDate]), "RatingDate", "PerformanceRating", List.Max)})
in
Custom1
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group