Forum Discussion

zibster's avatar
zibster
Helper III
6 years ago
Solved

New Column MAX

Hi,

 

I am trying to add a column that would identifie Max date place "CY" if the date = to max and place "CY" for others, here is my short code that i get error on.

= Table.AddColumn(#"Changed Type", "CyLy", each If(List.Max(#"Changed Type"[txn_dte])=[txn_dte],"CY","LY"))

 

Thanks

Z

  • VasTg's avatar
    VasTg
    6 years ago

    zibster 

     

    Add a custom column as below.

     

    = if [Txn_dte] = List.Max(#"Changed Type"[Txn_dte]) then "CY" else "LY"

     

     

     

     

    Edit: Remember to append previous step name to the column. In my case, "Changed Type" is the previous step and i am referring the date column as List.Max(#"Changed Type"[Txn_dte]) instead of List.Max([Txn_dte])

     

    If it helps, mark it as a solution

    Kudos are nice too

4 Replies

  • VasTg's avatar
    VasTg
    Memorable Member

    zibster 

     

    Please provide sample data  with expected output to answer the questions correctly.

      • VasTg's avatar
        VasTg
        Memorable Member

        zibster 

         

        Add a custom column as below.

         

        = if [Txn_dte] = List.Max(#"Changed Type"[Txn_dte]) then "CY" else "LY"

         

         

         

         

        Edit: Remember to append previous step name to the column. In my case, "Changed Type" is the previous step and i am referring the date column as List.Max(#"Changed Type"[Txn_dte]) instead of List.Max([Txn_dte])

         

        If it helps, mark it as a solution

        Kudos are nice too