Εκπαίδευση
Λειτουργική μονάδα
Transform data by implementing pivot, unpivot, rollup, and cube - Training
This content is a part of Transform data by implementing pivot, unpivot, rollup, and cube.
Αυτό το πρόγραμμα περιήγησης δεν υποστηρίζεται πλέον.
Κάντε αναβάθμιση σε Microsoft Edge για να επωφεληθείτε από τις τελευταίες δυνατότητες, τις ενημερώσεις ασφαλείας και την τεχνική υποστήριξη.
Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as table
Λαμβάνοντας υπόψη ένα ζεύγος στηλών που αντιπροσωπεύουν ζεύγη χαρακτηριστικού-τιμής, περιστρέφει τα δεδομένα στη στήλη χαρακτηριστικών σε επικεφαλίδες στηλών.
Λάβετε τις τιμές "a", "b" και "c" στη στήλη χαρακτηριστικών του πίνακα ({ [ key = "x", attribute = "a", value = 1 ], [ key = "x", attribute = "c", value = 3 ], [ key = "y", attribute = "a", value = 2 ], [ key = "y", attribute = "b", value = 4 ] })
και συγκεντρώστε τις στη δική τους στήλη.
χρήσης
Table.Pivot(
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]
}),
{"a", "b", "c"},
"attribute",
"value"
)
εξόδου
Table.FromRecords({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
})
Λάβετε τις τιμές "a", "b" και "c" στη στήλη χαρακτηριστικών του πίνακα ({ [ key = "x", attribute = "a", value = 1 ], [ key = "x", attribute = "c", value = 3 ], [ key = "x", attribute = "c", value = 5 ], [ key = "y", attribute = "a", value = 2 ], [ key = "y", attribute = "b", value = 4 ] })
και συγκεντρώστε τις στη δική τους στήλη. Το χαρακτηριστικό "c" για το κλειδί "x" έχει πολλές τιμές συσχετισμένες με αυτό, επομένως χρησιμοποιήστε τη συνάρτηση List.Max για να επιλύσετε τη διένεξη.
χρήσης
Table.Pivot(
Table.FromRecords({
[key = "x", attribute = "a", value = 1],
[key = "x", attribute = "c", value = 3],
[key = "x", attribute = "c", value = 5],
[key = "y", attribute = "a", value = 2],
[key = "y", attribute = "b", value = 4]
}),
{"a", "b", "c"},
"attribute",
"value",
List.Max
)
εξόδου
Table.FromRecords({
[key = "x", a = 1, b = null, c = 5],
[key = "y", a = 2, b = 4, c = null]
})
Εκπαίδευση
Λειτουργική μονάδα
Transform data by implementing pivot, unpivot, rollup, and cube - Training
This content is a part of Transform data by implementing pivot, unpivot, rollup, and cube.
Τεκμηρίωση
Table.AddColumn - PowerQuery M
Learn more about: Table.AddColumn
Table.SelectRows - PowerQuery M
Learn more about: Table.SelectRows
Table.TransformColumns - PowerQuery M
Learn more about: Table.TransformColumns