Forum Discussion

ds_br123's avatar
ds_br123
New Member
5 years ago

MoM calculation not working

Hi all!

 

I've been having some problems while I'm calculating MoM change. I'm going to detail the steps for my calculation below:

 

1. Calculate the running total of my variable with the following dax equation:

 

TotalRevenue running total = 
CALCULATE(
	[TotalRevenue]-[LostRevenueSum],
	FILTER(
		ALLSELECTED(DateTable[Date]),
		ISONORAFTER(DateTable[Date], MAX(DateTable[Date]), DESC)
	)
    ,USERELATIONSHIP(subscription[DateSubscribed],DateTable[Date])
)

 

 2. Calculate the MoM change%

 

TotalRevenue MoM% = 
	VAR __PREV_MONTH = CALCULATE([TotalRevenue running total], DATEADD(DateTable[Date], -1, MONTH),
    USERELATIONSHIP(subscription[DateSubscribed],DateTable[Date])
    )
	RETURN
		DIVIDE([TotalRevenue running total] - __PREV_MONTH, __PREV_MONTH,0)

 

 

The problem is that I get wrong results for the curret month (January in this case) as I show below (It should be 3.95%). I'm not sure why this is happening...

 

If I use the MoM change formula with a .[Date] like this, it works but creates an extra month 

 

TotalRevenue MoM% = 
	VAR __PREV_MONTH = CALCULATE([TotalRevenue running total], DATEADD(DateTable[Date].[Date], -1, MONTH),
    USERELATIONSHIP(subscription[DateSubscribed],DateTable[Date])
    )
	RETURN
		DIVIDE([TotalRevenue running total] - __PREV_MONTH, __PREV_MONTH,0)

 

 

Does anyone have any idea what I'm doing wrong?

5 Replies

  • ds_br123 mark your date table as date table and don't use .date.

     

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

  • ds_br123 just to confirm, in visual, you are showing date from date table, not your transaction table. Maybe easy if you share pbix file (remove sensitive information before sharing), you can share it thru one drive/google drive.

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi ds_br123 ,

     

    I guess it is because of the date hierarchy used in your table visual that caused this problem.
    If you don't use the date hierarchy and create year, quarter, and month columns, you will get the correct result.'

     

    Best regards,
    Lionel Chen

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

     

     

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi ds_br123 ,

     

    Has your problem been solved?

     

    Best regards,
    Lionel Chen

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