Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Date-over-Date calculation dividing two measures breaks relationship (e.g. YoY, MoM, etc)

I have spent about 2 hours searching around trying to find a solution, but I couldn't find anyone having the same issue and for which the solution solved my problem. The closest topics I've found wh...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    From what I am understanding, here's my solution.

    1.Create a calendar. If you have a calendar table yourself, you can use it directly.

    Calendar = CALENDAR(MIN('revenue'[date]),MAX('revenue'[date]))

    The relationships are as follows.

     

    2.Revenue M-1 and Revenue M-2 are as follows.

    Revenue M-1 = 
    var _date=SELECTEDVALUE('Calendar'[Date])
    var _end=EOMONTH(_date,-1)
    var _start=EOMONTH(_date,-2)+1
    return  CALCULATE(SUM(revenue[revenue]),FILTER('revenue',[date]>=_start&&[date]<=_end))
    Revenue M-2 = 
    var _date=SELECTEDVALUE('Calendar'[Date])
    var _end=EOMONTH(_date,-2)
    var _start=EOMONTH(_date,-3)+1
    return  CALCULATE(SUM(revenue[revenue]),FILTER('revenue',[date]>=_start&&[date]<=_end))

    Then you can calculate the MoM.

    MoM = DIVIDE([Revenue M-1]-[Revenue M-2],[Revenue M-2])

     

    3.The dates in the slicer are from the calendar table. For example, when you select '4/28/2021', the result is as follows.

     

    Best Regards,

    Stephen Tao

     

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