Reputation: 1
I am trying to get a helper value that changes if certain values change from the prior row. For instance, if the Site, Room or Cubicle value changes from the previous row, I want the helper value to increase by one. I am utilizing this method to separate specific data by row fill color utilizing conditional formatting. In a general workbook I can reference cells so a simple IF statement such as the following works.
=IF(AND(A3=A2, B3=B2, C3=C2),$E2, $E2+1)
Example of need Current workbook query
I am very new to utilizing power query and have no idea of how to get similar results. Below is an example of my first attempt, which clearly did not work.
I tried referencing the column-1. Additionally, as I cannot start with a value (1 in the prior example) in the first helper value cell, I cannot increase the value by one. Can anyone please assist?
Upvotes: 0
Views: 155
Reputation: 21393
Another method in Powerquery uses Table.Group with GroupKind set to local to increment an index any time Site/Room/Cubicle changes
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Special={"Site","Room","Cubicle"},
#"Grouped Rows" = Table.Group(Source, Special, {"data", each _, type table},GroupKind.Local),
#"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1, Int64.Type),
ColumnsToExpand =List.RemoveItems(List.Distinct(List.Combine(List.Transform(#"Grouped Rows"[data], each Table.ColumnNames(_)))),Special),
#"Expanded data" = Table.ExpandTableColumn(#"Added Index", "data", ColumnsToExpand ,ColumnsToExpand )
in #"Expanded data"
Upvotes: 1
Reputation: 2480
here is a workaround for you.
Upvotes: 1