Forum Discussion

RobertO995's avatar
RobertO995
Frequent Visitor
7 years ago
Solved

list max - function doesn't work properly

Hello all,   I need your help with List.Max in PowerBi. I'm totally new in M language and even simply things make a lot of troubles for me.   I have separated columns with date and year. For exam...
  • OwenAuger's avatar
    7 years ago

    RobertO995

    You can refer to the Year column of the table using the syntax PreviousStepName[Year], where PreviousStepName is the name of the step just before adding the Custom Column.

     

    So in the Custom Column dialog box, the code would look like:

    =List.Max( PreviousStepName[Year] )

    Regards,

    Owen

  • v-juanli-msft's avatar
    7 years ago

    Hi RobertO995

    You could take OwenAuger's advice, as tested, add a custom column using the following format 

    #"Changed Type" is the previous step

    List.Max(#"Changed Type"[Year])

    or write code in Advanced editor

    = Table.AddColumn(#"Changed Type", "Custom", each List.Max(#"Changed Type"[Year]))

    When i add year 2020 in my original table, then refresh from power bi desktop, it would automatically change to 2020 from 2019.

     

    Best Regards

    Maggie