Forum Discussion
Thoughtknotseer
3 years agoRegular Visitor
SelectRows apply to same column cause cyclic reference
Hi I have a table. ID Exam Score 1 A 50 2 A 60 3 A 40 4 B 30 5 B 20 6 B 40 Then I hope to add to prepare like below column for using post analysis. ...
- 3 years ago
Hi Thoughtknotseer ,
You can use the Group by Function in Power Query to achieve your desired result.
Copy the query below in advanced editor to see steps:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIEYlMDpVidaCUjKNcMwjWGck0gXBMg0wmIjSFcUyjXCMI1g3JBimMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Exam = _t, Score = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Exam", type text}, {"Score", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Exam"}, {{"MaxScore", each List.Max([Score]), type nullable number}, {"AllRows", each _, type table [ID=nullable number, Exam=nullable text, Score=nullable number]}}), #"Expanded AllRows" = Table.ExpandTableColumn(#"Grouped Rows", "AllRows", {"ID", "Score"}, {"ID", "Score"}) in #"Expanded AllRows"
wdx223_Daniel
3 years agoCommunity Champion
NewStep= let GpMx=Table.Buffer(Table.Group(PreviousStepName,"Exam",{"n",each List.MaxN(Table.ToRows([[Score],[ExamDate]]),1,each _{0}){0}})) in #table(Table.ColumnNames(PreviousStepName)&{"BestScore","BestDate"},List.Transform(Table.ToRows(PreviousStepName),each _&GpMx{[Exam=_{1}]}[n]))
Thoughtknotseer
3 years agoRegular Visitor
Thank you! I keep study to understand.