Showing results for 
Search instead for 
Did you mean: 
Helper IV
Helper IV

DATESMTD misbehaving if Sales in current month are zero

If Sales for Salesperson in current month = 0, the following DAX will then fetch the Sales Amount for the last month that it can see Sales (at least I think this is what is happening)


Sales MTD = CALCULATE([Amount Measure], DATESMTD('NAV_Sales History MASTER'[Posting Date]))
So in this example, Sales for Jan are £0 but it is returning Sales for December
For such a simple piece of DAX I'm struggling firstly to understand why it would retrieve the incorrect figure, and then why it would start looking for something outwith the current month?
Totals for Salespeople who have sales in the current month are displaying fine.
Any ideas at all?
Super User
Super User

I can't replicate that behaviour. Can you share a sample PBIX without any confidential information ?

Helper IV
Helper IV

Hi - Yes, all set up as such (changed Posting Date to my Date Table [Date] and same result. Otherwise, all is working fine with completely expected results across the board with the odd exception that if there are no sales in that month, then it will return the sales from the last month it can detect a sale in. There just seems no logic to why it would do that.

Super User
Super User

For the time intelligence functions to work correctly you need to have a proper date table marked as a date table. Set up a date table linked to your sales table and then use the date column from that as the parameter to DATESMTD

Helpful resources

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors