Forum Discussion

Ecan20's avatar
Ecan20
Frequent Visitor
5 years ago
Solved

Sum values until the first maximum value in another column per each category in another column

Hello DAX experts,  I have a dataset like the table below. I am looking for a DAX formula to return the sum of the values in DAY column until the values in DEPTH column reach the first maximum val...
  • Ecan20's avatar
    Ecan20
    5 years ago

    Amedeo, 

    I modified it a bit and I got what I needed. Instead of the single days (second column) I used the cumulative days as input.

    This formula returned the amount of days required to reach the final depth

     

    VAR_RESULT =
    CALCULATE (
    MIN (Table[DAY]),FILTER(Table, Table[DEPTH] = (MAX(Table[DEPTH]))))
     
    Many thanks for taking the time to help, much appreciated. 
    Regards
    Elena
  • Anonymous's avatar
    Anonymous
    5 years ago

    No need to apologize Ecan20 🙂 

    Yes, that would be a single measure, in which you can define multiple variables and reference them in the same measure. I assumed you were using a fairly recent version of Power BI Desktop/Excel, in which you can define variables.

    Are you using a recent version of Power BI Desktop/Excel/SQL Server Analysis Services?

    I don't want to ask a stupid question either, but have you forgot to provide a name for your measure? That's the first thing I can think of.

    If you miss that, you'll get an error:



    With measure name instead: