Divide multiple columns by one column (M)

Please find below a piece of code I developed in M to divide multiple columns by one column. Of course you can replace division by any other operation: 


"Divide Columns” = Table.FromRecords(Table.TransformRows(+"Name of previous step", (row) =>

       let

              targetColum = row[colum by which all the other will be divided],

              Transforms = List.Transform(

                     ("column to be transformed 1", "column to be transformed 2", "colum to be transformed 3"),

                     (name) => [ name, (cell) => cell / targetColum))

       in

 Record. TransformFields(row, Transforms)

)

)

"Divide Columns"


Let me know if any question.


Comentarios

Entradas populares