Forum Discussion
peterso
Helper II
6 years agoAdding custom rows in Power Query
Hi everyone, I've got a bit of an interesting problem here that I can't seem to solve. Wondering if you may know the answer to this. Based on each distinct "Assignment", I need to add two row...
- 6 years ago
Hello peterso
you can apply Table.Group twice to your orignal data and then combine your source with the results of your Table.Groups
Here the code to understand it better
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUrMq1QoSa0oATJNodjCQClWB0MWxDUD0UYQaSNUaWMgNgfTWCTBpoJooNZYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Assignment = _t, Scopes = _t, Labor = _t, Materials = _t, Rent = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assignment", Int64.Type}, {"Scopes", type text}, {"Labor", Int64.Type}, {"Materials", Int64.Type}, {"Rent", Int64.Type}}), CreateCustomTextRow = Table.Group(#"Changed Type", {"Assignment"}, {{"Rent", each List.Sum([Rent]), type number}, {"Scopes", each Text.From([Assignment]{0})&".CustomText"}}), CreateAnotherCustomTextRow = Table.Group(#"Changed Type", {"Assignment"}, {{"Rent", each 0, type number}, {"Scopes", each Text.From([Assignment]{0})&".AnotherCustomText"}}), Combine = Table.Combine({#"Changed Type", CreateCustomTextRow, CreateAnotherCustomTextRow}) in CombineCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
peterso
Helper II
6 years agoI don't quite understand. Can you explain please?
CNENFRNL
Community Champion
6 years agoPls refer to the attached file for the procedure.
- peterso6 years ago
Helper II
There is a circular reference error.