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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

MTD Measures Not Working

Hi All,

 

I am currently building a report that needs to show the MTD data for the current year and for several years in the past. I am unable to get even the "Month-To-Date Total" quick measure to work. Here is some sample data for the two columns I am working with:

 

policyNumberinceptionDate
BPP-2014-5481Tuesday,October 2, 2018
BPP-2014-5376Wednesday, October 3, 2018
BPP-2015-7130Wednesday, October 3, 2018
BPP-2015-7135Wednesday, October 3, 2018
BPP-2018-1121Thursday, October 4, 2018
BPP-2015-7136Friday, October 5, 2018
BPP-2019-1616Tuesday,October 1, 2019
BPP-2016-7654Tuesday, October 1,2019
BPP-2014-5481Wednesday, October 2,2019
BPP-2015-8258Wednesday, October 2,2019
BPP-2016-9318Thursday, October 3,2019
BPP-2015-7477Friday, October 4, 2019

 


I need the distinct count of policyNumbers for this month-to-date and MTD for October of 2018, October 2017, October 2016 etc. etc.

 

The "Month-To-Date Total" give me a result of "blank":

 

 

 

Count of policyNumber MTD =
IF(
    ISFILTERED('working_file'[inceptionDate]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
    TOTALMTD(
        COUNTA('working_file'[policyNumber]),
        'working_file'[inceptionDate].[Date]
    )
)

 

   
This measure gives me a completely incorrect result far below the actual distinct count:

 

MTD Policies = 
TOTALMTD ( DISTINCTCOUNT(working_file[policyNumber] ), working_file[inceptionDate])

 

 
This measure gives me the correct total FOR THE ENTIRE MONTH and not the MTD:

 

Current MTD FINAL =
CALCULATE(
    DISTINCTCOUNT('working_file'[policyNumber]),
    DATESBETWEEN(working_file[inceptionDate],DATE(YEAR(TODAY()), MONTH(TODAY()), 1),TODAY())
)​

 

 
Same as the code above, this code gives me the total for the entire month and not the MTD one year prior:
 

 

1 year MTD FINAL = 
CALCULATE(
	DISTINCTCOUNT('working_file'[policyNumber]),
	DATEADD(DATESBETWEEN(working_file[inceptionDate],DATE(YEAR(TODAY()), MONTH(TODAY()), 1),NOW()),-1,YEAR)
)

 

 I've spent a great deal of time on this and have yet to come up with a solution.
Would greatly appreciate some guidance!
1 ACCEPTED SOLUTION
elxinside
Frequent Visitor

Hi @Anonymous ,

from what you say I don't understan what you are using as a time reference. In order to have time intelligence functions to work you need to have a "calendar table" with all the dates in the time interval you are considering.

You can easily build it with calendar() function. https://docs.microsoft.com/en-us/dax/calendar-function-dax

Once you have it, you should connect the date in the calendar table to your inceptiondate and you should use the date in the calendar table as reference for time intelligence dax functions.

 

View solution in original post

2 REPLIES 2
elxinside
Frequent Visitor

Hi @Anonymous ,

from what you say I don't understan what you are using as a time reference. In order to have time intelligence functions to work you need to have a "calendar table" with all the dates in the time interval you are considering.

You can easily build it with calendar() function. https://docs.microsoft.com/en-us/dax/calendar-function-dax

Once you have it, you should connect the date in the calendar table to your inceptiondate and you should use the date in the calendar table as reference for time intelligence dax functions.

 

Anonymous
Not applicable

Thank you, @elxinside! I am fairly new to Power Bi and did not realize I needed to have that calendar table for time intelligence functions. This not only fixed my MTD measures but I was also able to fix my 12 Month Rolling measures & YTD measures.

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors