none
Index Based On Other Column Value (Start from 0 if when value changes) RRS feed

  • Question

  • Dear, 

    Please suggest an easy and understandable way to index in Power Query base on other column value. Function/Method

    <style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
    Name Index
    Andrew 0
    Andrew 1
    Andrew 2
    Andrew 3
    Mike 0
    Mike 1
    Mike 2
    Mike 3
    Mike 4
    Bill 0
    Bill 1
    Bill 2
    Bill 3
    Bill 4
    Bill 5

    Regards

    Dilawer

    Sunday, April 14, 2019 11:13 AM

Answers

  • Hi Dilawer,

    Suppose, you have such dataset:

    

    Then, in my opinion, the following method is quite easy and understandable:

    let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], group = Table.Group(Source, {"Name"}, {"temp", each Table.AddIndexColumn(_,"Index",0,1)}), expand = Table.ExpandTableColumn(group, "temp", {"Data", "Index"}) in expand

    Monday, April 15, 2019 11:00 AM

All replies