Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created December 18, 2019 16:06
Show Gist options
  • Save ImkeF/64753d27a9cf23e6e002c683db77453e to your computer and use it in GitHub Desktop.
Save ImkeF/64753d27a9cf23e6e002c683db77453e to your computer and use it in GitHub Desktop.
Transforms all columns of a <code>table</code> with one <code>function</code> and one <code>type</code>.
let func =
(Table as table, Function, TypeForColumns as type, optional ColumnNames as list) =>
let
columnNames = if ColumnNames = null then Table.ColumnNames(Table) else ColumnNames,
Transformation = Table.TransformColumns( Table, List.Transform(columnNames, each {_, Function, TypeForColumns} ) )
in
Transformation ,
documentation = [
Documentation.Name = " Table.TransformAllColumns.pq ",
Documentation.Description = " Transforms all columns of a <code>table</code> with one <code>function</code> and one <code>type</code>. ",
Documentation.LongDescription = " Transforms all columns of a <code>table</code> with one <code>function</code> and one <code>type</code>. Optionial <code>ColumnNames</code> to limit to a specific list. ",
Documentation.Category = " Table ",
Documentation.Source = " www.TheBIccountant.com https://wp.me/p6lgsG-2dQ . ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Imke Feldmann ",
Documentation.Examples = {[Description = " ",
Code = " TableTransformAllColumns( #table( {""TextColumn1"", ""TextColumn2""}, List.Zip( { {""123<code>456</code>"" ,""789<code>101</code>""}, {""ABC<code>DEF</code>"" ,""GHI<code>JKL</code>""} } ) ), fnRemoveHtmlTags, type text) ",
Result = " #table( {""TextColumn1"", ""TextColumn2""}, List.Zip( { {""123456"" ,""789101""}, {""ABCDEF"" ,""GHIJKL""} } ) ) "]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment