Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

DAX Measure - Current Week Amount

I have created a dax measure to calculate the Current Overdue Amount for each customer in a table. The measure is formulated as follows: =VAR CurrDate = MAX('f_AR_Trend'[AS OF DATE]) VAR CurrOD =...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    Your solution is great, lbendlin. It worked like a charm! Here I have another idea in mind, and I would like to share it for reference.

     

    I created serval measures as follow.

    AS = MAX([AS OF DATE])
    rank = RANKX(ALLEXCEPT(Source, Source[Customer]), [AS], , DESC, Dense)
    Current Date = 
    VAR _total = CALCULATE(MAX([Total Overdue]), FILTER(Source, [AS OF DATE] = SELECTEDVALUE('Table'[Date])))
    RETURN
    IF(_total = BLANK(), 0, _total)
    Previous Date = 
    VAR _rank = MAXX(FILTER(Source, [AS OF DATE] = SELECTEDVALUE('Table'[Date])), [rank])
    VAR _lastdate = CALCULATE(MAX([AS OF DATE]), FILTER(ALL(Source), [rank] = 2))
    VAR _total = CALCULATE(MAX([Total Overdue]), FILTER(ALLEXCEPT(Source, Source[Customer]), [AS OF DATE] = _lastdate))
    RETURN
    IF(_total = 0, 0, MAX([Total Overdue]))

     

    Result:

     

    Best Regards,
    Yulia Xu

     

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