Forum Discussion

ChemEnger's avatar
ChemEnger
Icon for Advocate V rankAdvocate V
2 years ago
Solved

Dynamically apply column transformations

I have a 'data' table where I'd like to dynamically change the number of decimal places. I use a 'dictionary' table that holds the names of the columns in 'data' along with the desired number of dec...
  • ImkeF's avatar
    2 years ago

    Hi ChemEnger ,
    it could work like so:

    (InputTable as table, dictionary as table) =>
      let
        TransformFunctionList = List.Transform(
          Table.ToRecords(dictionary), 
          (record) => {record[ColumnName], each Number.Round(_, record[Decimal]), type number}
        ), 
        Transform = Table.TransformColumns(InputTable, TransformFunctionList)
      in
        Transform

     No real recursion needed. Just transform your dictionary table into a list of records and create the transformation list elements out of it.