Forum Discussion

ErinKlomp's avatar
ErinKlomp
New Member
2 years ago
Solved

Power Query index that resets when one column changes

Hi everyone,   I am a first time user of Power Query and am stuck. I have no experience with similar software.   I want to create an index, which resets to 1 when one column changes value. As an ...
  • dufoq3's avatar
    2 years ago

    Hi ErinKlomp,

     

    Group Rows:

     

    Change the code of Grouped rows where you replace _ with Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type) and remove RED part of that code.

     

    = Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})

     

     

    Expand columns you want (unthick Use original column name as prefix)

     

    You can find whole code with sample data included here (you have to replace whole code with this one via Advanced Editor):

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrU0NDFU0lEyMjU3MjNSitVBEzLGFDLDFLKACxmBhcwsLLEIWaILWRoYYwqZKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [evaluatieperiodeid = _t, respondentid = _t]),
        GroupedRows = Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})
    in
        GroupedRows