Video summary
Table.TransformColumns in Power Query | Super Function ⚡
Main summary
Key takeaways
Summary
The video explains how to use Power Query’s Table.TransformColumns function directly in M code. The function applies transformations to existing columns, and writing it manually can provide more flexibility than relying only on the Power Query interface.
Basic structure
- The first argument is the table to transform, usually the previous query step.
- The second argument is a list of column transformations.
- Each column transformation is a list containing:
- The column name, written as text.
- A transformation function.
- Optionally, the resulting data type.
- For multiple columns, place each transformation in its own inner list, separated by commas.
- The transformation function can use
eachto process values row by row. The underscore (_) refers to the current value being transformed.
Examples and techniques
-
Replace a column’s values with a conditional result
- The example checks whether each value in the
Agecolumn is greater than 10. - It replaces each age with
trueorfalseusing anif … then … elseexpression. - The results can then be filtered to keep only
truerows. Because the original ages have been replaced, theAgecolumn can be removed if it is no longer needed.
- The example checks whether each value in the
-
Transform and validate multiple columns
- The example transforms
AgeandDate of Joiningin the sameTable.TransformColumnscall. - For
Age,Value.Typeis used to check whether each value is a number; the result can be turned into a Boolean validation flag. - For
Date of Joining,Date.Fromattempts to convert each value to a date. - Invalid date values produce errors unless the conversion is wrapped in
try … otherwise. The example uses this pattern to returnfalsewhen conversion fails. - A data type can optionally be specified after a column’s transformation function.
- The example transforms
-
Handle columns that may be missing
- By default, transforming a column that does not exist in the table causes an error.
- The video demonstrates using the optional
missingFieldargument withMissingField.Ignoreso the query can continue when a listed column is absent.
-
Convert files directly within a column
- When importing files from a folder, the
Contentcolumn contains binary file data. - Instead of adding a separate custom column,
Table.TransformColumnscan applyExcel.Workbookto each binary value. - The example uses
each Excel.Workbook(_, true), withtrueindicating that the first row should be promoted as headers.
- When importing files from a folder, the
Main takeaway
Table.TransformColumns is useful for transforming one or more existing columns in place, applying row-by-row logic, handling conversion errors, tolerating missing fields, and processing values such as Excel-file binaries without creating an extra column.
Speakers and sources
- Chandeep, the presenter from the Goodly channel.
- Excel and Power Query are demonstrated as the software tools; no other speakers are identified.
- Music is heard briefly, but the subtitles do not identify its source.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.