Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Return Value based on highest number, comparing rows

Dear reader,   A demo from what the data looks like: ID                           Value       YearMonth CustomerA             $50          202009 CustomerA             $50          202008 Custo...
  • amitchandak's avatar
    5 years ago

    Anonymous , Try

    new column = if([YearMonth] = maxx(filter(table, [ID] = earlier([ID])),[YearMonth]),1,0)

    or

    new measure = if(max(Table[YearMonth]) = maxx(filter(allselected(table), [ID] = max([ID])),[YearMonth]),1,0)

  • v-alq-msft's avatar
    5 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    You may create a custom column with following m codes.

    let 
    id=[ID],
    maxyearmonth=List.Max(
        Table.SelectRows(#"Changed Type",each [ID]=id)[YearMonth]
    )
    in 
    if [YearMonth]=maxyearmonth
    then 1 else 0

     

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.