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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
andrewb95
Helper II
Helper II

MTD - Calculation not working

PhotoforPBX-Community.PNG

Please see the image above, I have attempted to calculate the count for the month to date as you can see. I would expect on the 15/09 as I am perfoming this calculation it should return 145 adding up all the values in red. However for some reason it is only providing 2. Can you advise why. 

 

FYI: The field types are Whole Number and Date respectivly. 

 

6 REPLIES 6
vishwajeet121
Frequent Visitor

MTD =
CALCULATE (
    SUM ('table'[Count]),
    FILTER (
        ALL ('table'),
            'table'[Date]<= MAX ('table'[Date]))
          )
 
this formula works for me and if you want to add the specific filter please add after ALL
 
MTD =
CALCULATE (
    SUM ('table'[Count]),
    FILTER (
        ALL ('table'),'table'[Defect Category - 1]="KK"&&
            'table'[Date]<= MAX ('table'[Date]))
          )
v-kkf-msft
Community Support
Community Support

Hi @andrewb95 ,

 

Has your problem been solved? If it is solved, please mark a reply which is helpful to you.

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

CNENFRNL
Community Champion
Community Champion

= 
CALCULATE(
    SUM( 'Total-Count'[Count] ),
    DATESMTD( 'Total-Count'[Date] ),
    REMOVEFILTERS( 'Total-Count'[Date] )
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@andrewb95 , You should always use date table joined with date of your table

 

calculate(sum('Total -Count'[Count]), datesmtd('Date'[Date]))

 

Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit, 

 

When creating a relationship to the date table (which I have updated as indicated above) the value actually changes to null so this is very unusual. 

 

 

Hi @andrewb95 ,

 

I could not reproduct your problem. Maybe you can try the following measures:

 

Measure1 = 
CALCULATE(
    SUM('Total - Count'[Count]),
    ALL('Total - Count'[Date]),
    DATESMTD('Total - Count'[Date])
)
Measure2 = 
CALCULATE (
    SUM ( 'Total - Count'[Count] ),
    FILTER (
        ALL ( 'Total - Count' ),
        'Total - Count'[Date] <= TODAY ()
            && 'Total - Count'[Date] <= MAX ( 'Total - Count'[Date] )
            && FORMAT ( 'Total - Count'[Date], "yyyymm" )
                = FORMAT ( MAX ( 'Total - Count'[Date] ), "yyyymm" )
    )
)

image.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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