Forum Discussion

lennardheyder's avatar
lennardheyder
Frequent Visitor
5 years ago
Solved

Dynamic column choice if null for index needed

Dear colleagues, I want to define an index in a column. This index should be next available record in one of the columns. For each quarter there is column, the index column should show the most earli...
  • Anonymous's avatar
    Anonymous
    5 years ago

    given the limited information you provide it is not possible to provide a suitable answer for general cases. I give you an idea of what can be done, based on what I understand for what you ask. The answer can be improved, but you must also collaborate, providing more precise information on the structure of your data and loading tables that can be copied: one the starting one and the other desired.

  • Anonymous's avatar
    Anonymous
    5 years ago

    You can use the null coalescing operator:

    Table.AddColumn(TableName, "Index", each [Column1]??[Column2]??[Column3]??[Column4]??"Default Value")

     

    Which is if Column1 =null then Column2 unless Column 2 is null then Column3 unless Column3 is null then Column4 unless Column4 is null then use Default Value.

    --Nate