Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cwayne758
Helper IV
Helper IV

Time Intelligence: TOTALMTD vs DATESMTD vs DATEADD

Hi,

 

I am trying to have a floating measure that tells us the total write-off amounts from the start of the current month to the current day in the current month.

 

I have done this 3 different ways. 2 of my 3 give me the same answer. 

 

Photo attached: 

MTD.PNGmtd1.PNGmtd2.PNG

Thanks in advance 🙂 

1 ACCEPTED SOLUTION

If you want to understand time intelligence better in DAX, read this excellent blog post.

 

In short here is the behavior of the three functions you mentioned.

 

TOTALMTD(): This is only syntactic sugar, all it does is give you the following:

CALCULATE(
    [measure]
    ,DATESMTD(DimDate[Date])
)

DATESMTD(): This works in a date dimension, which must have contiguous, nonrepeating dates from January 1 of the first year you have data to December 31 of the last year you have data. The function returns a 1 column table made up of dates between the first of the month of the current date in context and the current date in context.

 

DATEADD(): This essentially gives you a range of dates (one column table) based on the number of intervals you've requested in either direction. It does not behave intuitively compared to a DATEADD() function in any other language, and I am not aware of any circumstances we (we being a Microsoft BI consultancy with a number of DAX experts) have decided this is the right function to use for any of our work. There is a good description in the linked blog post at the top of my reply.

View solution in original post

16 REPLIES 16

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.