Forum Discussion
Month-To-Date Fails
Hi
I have a report in which I was calculating Month-To-Date and Year-To-Date values using TOTALMTD and TOTALYTD functions respectively, successfully. But after crossing over into this year 2021, the Month-To-Date is no longer working (gives (Blank)) but the Year-To-Date still working correctly.
I have recreated the issue using a simple Data table with three columns:-
RecordID with 64 unique rows;
RecordDate with dates from 1st January to 8th January 2021 (today is 9th January where I am);
RecordAmount with currency values that total 8,112,554.00
I also have a Date table with a Start Date of 01/01/2021 and End Date of 31/12/2021.
I have a one-to-many relationship between the Date in Date table and RecordDate in Data table.
DAX:
The count and sum are calculated using the formulas:
TotalCount = COUNT ( Data[RecordID] )
TotalValue = SUM ( Data[RecordAmount] )
The Year-To-Date formulas are as follows, giving the result as 64 for count and 8,112,554.00 for value:
YTDCount = TOTALYTD( [TotalCount], 'Date'[Date] )
YTDValue = TOTALYTD( [TotalValue], 'Date'[Date] )
However the following Month-To-Date formulas are giving (Blank) result:
MTDCount = TOTALMTD( [TotalCount], 'Date'[Date] )
MTDValue = TOTALMTD( [TotalValue], 'Date'[Date] )
MTDValue2 =
CALCULATE(
[TotalValue], DATESMTD('Date'[Date])
)
Ideally, since we are in the first month of the year, the Month-To-Date formulas should give the same result as the Year-To-Date.
But why are these Month-To-Date formulas not working? Where am I going wrong? Why were they working till 31st December 2020?
Here's the Data table data:
| RecordID | RecordDate | RecordAmount |
| RID2429539 | 01/01/2021 | 2,550.00 |
| RID6266391 | 01/01/2021 | 8,542.00 |
| RID2766210 | 01/01/2021 | 4,785.00 |
| RID7121254 | 01/01/2021 | 74,186.00 |
| RID5948116 | 01/01/2021 | 362,514.00 |
| RID7469708 | 01/01/2021 | 26,987.00 |
| RID4099682 | 01/01/2021 | 478,963.00 |
| RID9509023 | 01/01/2021 | 96,857.00 |
| RID2613884 | 02/01/2021 | 579,246.00 |
| RID2383164 | 02/01/2021 | 6,985.00 |
| RID8757668 | 02/01/2021 | 54,879.00 |
| RID2807380 | 02/01/2021 | 16,487.00 |
| RID6370155 | 02/01/2021 | 5,241.00 |
| RID5565518 | 02/01/2021 | 621,687.00 |
| RID8887687 | 02/01/2021 | 147,896.00 |
| RID9705440 | 02/01/2021 | 321,654.00 |
| RID8352549 | 03/01/2021 | 21,258.00 |
| RID5101320 | 03/01/2021 | 3,254.00 |
| RID4619599 | 03/01/2021 | 3,659.00 |
| RID5324070 | 03/01/2021 | 23,568.00 |
| RID1048844 | 03/01/2021 | 5,263.00 |
| RID2355883 | 03/01/2021 | 489,423.00 |
| RID3421876 | 03/01/2021 | 123,698.00 |
| RID4205516 | 03/01/2021 | 123,456.00 |
| RID2795710 | 04/01/2021 | 7,125.00 |
| RID4608426 | 04/01/2021 | 32,584.00 |
| RID5331781 | 04/01/2021 | 365,987.00 |
| RID9656979 | 04/01/2021 | 35,358.00 |
| RID7554543 | 04/01/2021 | 2,546.00 |
| RID4442667 | 04/01/2021 | 95,623.00 |
| RID9181870 | 04/01/2021 | 7,598.00 |
| RID6379809 | 04/01/2021 | 2,587.00 |
| RID6173906 | 05/01/2021 | 21,578.00 |
| RID8194349 | 05/01/2021 | 336,987.00 |
| RID9033769 | 05/01/2021 | 2,579.00 |
| RID9190427 | 05/01/2021 | 69,874.00 |
| RID3422034 | 05/01/2021 | 5,213.00 |
| RID5138204 | 05/01/2021 | 95,847.00 |
| RID2159283 | 05/01/2021 | 9,587.00 |
| RID9181135 | 05/01/2021 | 2,589.00 |
| RID9359735 | 06/01/2021 | 63,636.00 |
| RID7090909 | 06/01/2021 | 9,482.00 |
| RID7607672 | 06/01/2021 | 8,417.00 |
| RID7102174 | 06/01/2021 | 784,512.00 |
| RID5427435 | 06/01/2021 | 3,578.00 |
| RID8586926 | 06/01/2021 | 25,697.00 |
| RID9936332 | 06/01/2021 | 4,718.00 |
| RID5892430 | 06/01/2021 | 4,736.00 |
| RID7347527 | 07/01/2021 | 5,798.00 |
| RID2407183 | 07/01/2021 | 91,917.00 |
| RID9203121 | 07/01/2021 | 8,954.00 |
| RID5012546 | 07/01/2021 | 895,623.00 |
| RID9538098 | 07/01/2021 | 1,598.00 |
| RID3978041 | 07/01/2021 | 4,781.00 |
| RID8304120 | 07/01/2021 | 362,514.00 |
| RID7172606 | 07/01/2021 | 6,914.00 |
| RID3717525 | 08/01/2021 | 1,247.00 |
| RID7635973 | 08/01/2021 | 125,469.00 |
| RID6303242 | 08/01/2021 | 96,578.00 |
| RID2186318 | 08/01/2021 | 695,847.00 |
| RID7365305 | 08/01/2021 | 24,987.00 |
| RID7577468 | 08/01/2021 | 47,547.00 |
| RID8111352 | 08/01/2021 | 85,749.00 |
| RID8044283 | 08/01/2021 | 55,555.00 |
Mirithu probably your date table is till end of the month and it is calculating MTD for dec 2021, you need to restrict it until TODAY(), update your measure like this
MTD = TOTALMTD ( SUM ( 'MTD'[RecordAmount] ), CALCULATETABLE ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] <= TODAY() ) )Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
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.⚡
3 Replies
- parry2kSuper User
Mirithu probably your date table is till end of the month and it is calculating MTD for dec 2021, you need to restrict it until TODAY(), update your measure like this
MTD = TOTALMTD ( SUM ( 'MTD'[RecordAmount] ), CALCULATETABLE ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] <= TODAY() ) )Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020
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.⚡
- Ashish_MathurSuper User
Hi,
To your visual, if you have dragged year and Month name from the Date Table, then you need not write seperate measures for the MTD. MTD should be TotalCount and Totalvalue measures itself.
- MirithuHelper II