Move up values when null Power Query

后端 未结 1 1767
梦谈多话
梦谈多话 2021-01-27 08:35

At this moment I have a big table in Excel that I would like to use with dynamic dropdown (cascade options). Depending on the selection you do on the first dropdown, then in the

1条回答
  •  醉话见心
    2021-01-27 09:05

    Since the columns are independent, you can turn each one into a list, remove the nulls, then combine them back into a table.

    Table.FromColumns(
        {
            List.RemoveNulls(Pivot[C1]),
            List.RemoveNulls(Pivot[C2]),
            List.RemoveNulls(Pivot[C3])
        },
        {"C1","C2","C3"}
    )
    

    Result:

    This can be made more dynamic if the number of columns isn't always three but the same idea should apply.


    Edit:

    It's actually simpler than I initially anticipated to make this dynamic, independent of the number of columns and their names:

    Table.FromColumns(
        List.Transform(Table.ToColumns(Pivot), List.RemoveNulls), 
        Table.ColumnNames(Pivot)
    )
    

    0 讨论(0)
提交回复
热议问题