Compartir vía


Table.Unpivot

Syntax

Table.Unpivot(
    table as table,
    pivotColumns as list,
    attributeColumn as text,
    valueColumn as text
) as table

Acerca de

Convierte un conjunto de columnas de una tabla en pares atributo-valor, combinados con el resto de los valores de cada fila.

Ejemplo 1

Tome las columnas "a", "b" y "c" de la tabla ({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]}) y despivote en pares de atributo-valor.

Uso

Table.Unpivot(
    Table.FromRecords({
        [key = "x", a = 1, b = null, c = 3],
        [key = "y", a = 2, b = 4, c = null]
    }),
    {"a", "b", "c"},
    "attribute",
    "value"
)

Salida

Table.FromRecords({
    [key = "x", attribute = "a", value = 1],
    [key = "x", attribute = "c", value = 3],
    [key = "y", attribute = "a", value = 2],
    [key = "y", attribute = "b", value = 4]
})