Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Else if function displaying the max date

Hi there   I want to create a calculated column which includes text and also a max date. Below is what I want to do, but M Query doesn't like it because I can only see options for a List.Max which ...
  • MFelix's avatar
    6 years ago

    Hi Anonymous ,

     

    M language is based on the row levels to get the maximum of a column for example as you refer you need to pick up the List.Max.

     

    Assuming that you want to pick up the maximum value of the duration column you need to do your column like:

    = Table.AddColumn(Between, "Column", each if [Duration] >= 60 then "60 to " & 
    Number.ToText (List.Max(#"PreviousStepName"[Duration])) else if [Duration] >= 30 then "30 to 59" else if [Duration] >= 11 then "11 to 29" else "0 to 10")

    I'm assuming that your duration column is in number format that is why we need to use the Number.ToText.

     

    Also using the List.Max you need to reference the step you want to calculate the maximum and the column thats the part 

    List.Max(#"PreviousStepName"[Duration])