Hassan
Hassan

Reputation: 54

PREVIOUSMONTH formula not being displayed in Card visual

I am trying to show the last month Cost by default on the page in a Card visual. with no filter selected, it should show the last month Cost (in our case, show September Cost).

Measure Formula:

Cost (LM) = CALCULATE([Total Cost], PREVIOUSMONTH(DATESYTD('Calendar'[Date])))

I added DATESYTD as in this hack worked for Last Year's Cost measure.

Upvotes: 0

Views: 23

Answers (2)

Hassan
Hassan

Reputation: 54

I did some digging and I found out 2 issues:

  1. My calendar (which is automatically created by the CALENDAR() function) was taking the end of the maximum year and creating the calendar. (e.g. maximum available year is 2024, so the calendar was created until December 31, 2024). Solution: Create it till the last possible date or end of month of that date.
  2. I should have used DATESMTD instead of DATESYTD (Duh) (We thank Amira Bedhiafi from the comments for that).

Upvotes: 0

Amira Bedhiafi
Amira Bedhiafi

Reputation: 1

Simply focus on PREVIOUSMONTH directly without DATESYTD since it is typically used for cumulative totals over a year and not only for the last month :

Cost (LM) = 
CALCULATE([Total Cost], PREVIOUSMONTH('Calendar'[Date]))

Upvotes: 1

Related Questions