1

How do you normalise all columns by their maximum value?

See the following table which we start with:

enter image description here

The result should be that all columns are divided by their own maximum value, as such:

enter image description here

The Power Query script should:

  • Apply to all columns, the number of columns is dynamic
  • The columns should be divided by their own maximum value
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Interesting question! Not too difficult if you are comfortable working with M in the Advanced Editor rather than just relying on the GUI.

let
    Source = <Data Source Here>,
    ToColumns = Table.ToColumns(Source),
    DivideByMax = List.Transform(ToColumns,
                      (Col) => List.Transform(Col, each _ / List.Max(Col))
                  )
    Result = Table.FromColumns(DivideByMax, Table.ColumnNames(Source))
in
    Result

What this does is take the table and transform it into a list of lists (columns). Then it transforms each list/column by dividing each element of that list by the max of that list/column. Finally, it transforms the list of lists back into a table using the column names from the first step.

Alexis Olson
  • 38,724
  • 7
  • 42
  • 64
  • 1
    This is a very nice and elegant solution, thanks! Only thing: You missed a bracket after <(Col) => List.Transform(Col, each _ / List.Max(Col))> – InteressantPunt Jan 10 '19 at 09:06