Table.UnpivotOtherColumns
Converts all columns, except for a defined set, into attribute-value pairs, while retaining the original values in each row.
Table.UnpivotOtherColumns(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table
Converts all columns, except for a defined set, into attribute-value pairs, while retaining the original values in each row.
Converts all columns, except for a specified set, into attribute-value pairs. This function combines these attribute-value pairs with the remaining values in each row.
To use this function in Power Query, you can call `MTable.UnpivotOtherColumns` and provide the necessary arguments as shown in the example below:
```
MTable.UnpivotOtherColumns(
Table.FromRecords({
[key = "key1", attribute1 = 1, attribute2 = 2, attribute3 = 3],
[key = "key2", attribute1 = 4, attribute2 = 5, attribute3 = 6]
}),
{"key"},
"column1",
"column2"
)
```
The output will be a table created using the `OutputTable.FromRecords` function, displaying the data in the format of attribute-value pairs:
```
Table.FromRecords({
[key = "key1", column1 = "attribute1", column2 = 1],
[key = "key1", column1 = "attribute2", column2 = 2],
[key = "key1", column1 = "attribute3", column2 = 3],
[key = "key2", column1 = "attribute1", column2 = 4],
[key = "key2", column1 = "attribute2", column2 = 5],