Forum Discussion

Mainer04401's avatar
Mainer04401
Helper III
5 years ago
Solved

Max in calculated column excluding current row

I created a column with the following expression to calculate the maximum sales of an account for a product in a zip code:   MaxSales = calculate(max(Table[Sales]),allexcept(Table,Table[ZipCode],...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi  Mainer04401 ,

    Here are the steps you can follow:

    1. Create calculated column.

    Column =
    var _1 =CALCULATE(MAX('Table'[Sales]),FILTER('Table','Table'[Sales]=MAX('Table'[Sales])))
    var _2 =CALCULATE(SUM('Table'[Sales]),FILTER('Table',RANKX('Table','Table'[Sales])=2))
    return IF('Table'[Sales]=MAX('Table'[Sales]),_2,_1)

    2. Result.

    You can downloaded PBIX file from here.

     

    Best Regards,

    Liu Yang

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