Forum Discussion

smpa01's avatar
smpa01
Community Champion
3 years ago
Solved

Unpivot Others with null

The following currently eliminates all nulls   = Table.UnpivotOtherColumns( Table.FromRecords({ [key = "key1", attribute1 = 1, attribute2 = null, attribute3 = 3], [key = "key...
  • ImkeF's avatar
    3 years ago

    Hi smpa01 ,
    yes, no need for an (un)pivot operation here. The following method will keep all values by default:

    let
        Custom1 = Table.FromRecords({
            [key = "key1", attribute1 = 1, attribute2 = null, attribute3 = 3],
            [key = "key2", attribute1 = 4, attribute2 = 5, attribute3 = 6]
        }),
        #"Added Custom" = Table.AddColumn(Custom1, "OtherValues", each Record.ToTable(Record.RemoveFields(_, {"key"}))),
        #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"key", "OtherValues"}),
        #"Expanded OtherValues" = Table.ExpandListColumn(#"Removed Other Columns", "OtherValues"),
        #"Expanded OtherValues1" = Table.ExpandRecordColumn(#"Expanded OtherValues", "OtherValues", {"Name", "Value"}, {"Name", "Value"})
    in
        #"Expanded OtherValues1"