Forum Discussion
SuperSayan
Resolver I
8 years agonew column depending on value from another row
Hi everyone, My dashboard is almost completed but I'm hitting a last minute bump road. My main data table is a record of intervention performed by technicians. I have different type of interven...
- 8 years ago
You can use Group By in Power Query (M).
I added a temporary Index to have the results sorted back to the original sort order, which may not be relevant for you.
You can generate initial code by grouping on "Code implantation" and "Fin réelle", with operation minimum for the service and operation "all rows", and then adjust the generated code (see below).
let Source = Table1, #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1), #"Grouped Rows" = Table.Group(#"Added Index", {"Code implantation", "Fin réelle"}, {{"New Column", each List.Min({1,List.Count(List.Select([Service], each Text.StartsWith(_,"V")))}), Int64.Type}, {"AllData", each _, Value.Type(#"Added Index")}}), #"Expanded AllData" = Table.ExpandTableColumn(#"Grouped Rows", "AllData", {"Service", "Index"}), #"Reordered Columns" = Table.ReorderColumns(#"Expanded AllData",{"Code implantation", "Service", "Fin réelle", "New Column"}), #"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Index", Order.Ascending}}), #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"}) in #"Removed Columns"