Forum Discussion

Syrathos's avatar
Syrathos
New Member
3 years ago
Solved

Index (Or Equivalent) that skips existing values (different row).

I have spent hours googling and trying various things to no avail so I thought I'd check in with the helpful individuals here.   I have a table in Excel which I am manipulating using power query: ...
  • AlienSx's avatar
    AlienSx
    3 years ago

    Syrathos 

    let
        Source = your_table,
        group = Table.Group(Source, {"Code"}, {{"all", each fx_tbl(_)}}),
        fx_tbl = (tbl as table) as table =>
            [a = Table.AddColumn(tbl, "sorting", each if List.Contains({null, "", " "}, [Related ID]) then [Index] else [Related ID] - .1),
            b = Table.Sort(a, "sorting"),
            idx = Table.AddIndexColumn(b, "Desired", 1, 1)][idx],
        z = Table.RemoveColumns(Table.Combine(group[all]), "sorting")
    in
        z