Forum Discussion

gmasta1129's avatar
gmasta1129
Resolver I
4 years ago
Solved

Month over month difference

  Hello,   I am trying to find the difference in values month over month.  For example, from 11/30/2021 to 12/31/2021 the difference is 405,906 ( total value usd column 11.30 14,407,600 minus tota...
  • v-henryk-mstf's avatar
    4 years ago

    Hi gmasta1129 ,

     

    For this type of problem, you need to create a calendar table and link this table to your factual data table by date. You cannot reference the date of the data table directly in the PREVIOUSMONTH function.

    M_result =
    CALCULATE (
        SUM ( 'Table'[total value usd] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Col_2] = MAX ( 'Table'[Col_2] ) )
    )
        - CALCULATE ( [M_sum], PREVIOUSMONTH ( Tab_cal[Date] ) )

    related blog and solution as below:

    DAX - PREVIOUSMONTH Function - Power BI Docs

    Solved: Error with PREVIOUSMONTH - duplicatedates - Microsoft Power BI Community


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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