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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
loodle
Frequent Visitor

Help with MTD Measure

Just trying to use the MTD function for the following data:

 

Record NumberRepair DateStatus
11/1/2022Closed
23/4/2022Closed
3 Active
43/4/2022Closed
53/18/2022Closed
6 Active

 

I have followed the instructions to create a Date Table, but can't figure out how to get a MTD count of Closed Records. I thought it was be something like this: 

CLOSED MTD =
TOTALMTD(
    DISTINCTCOUNT ([RECORDNUMBER]),
    'DATE'[Date]
1 ACCEPTED SOLUTION

Haha, i don't understand these MTD formulas at all 😂

How about something more lowkey like:

This month = 
CALCULATE(
    DISTINCTCOUNT('Tabel (2)'[Record Number])
    ,FILTER('Calendar', 
        'Calendar'[Date] <= EOMONTH(TODAY(),0)
        && 'Calendar'[Date] >= (EOMONTH(TODAY(),-1)+1)

    )
)

Should give you data between 01-06-2022 and 31-06-2022


View solution in original post

10 REPLIES 10
ghoshabhijeet
Solution Supplier
Solution Supplier

@loodle  Does your record table have data for Today? Will be able to help better if you could provide the PBIX file with some sample data. Thanks !

NickolajJessen
Solution Sage
Solution Sage

I'm not sure why you need this one MTD setup?

can't you just make a COUNT and add a relate date filter to the visual saying In this month?

I am trying to create a table that has other columns that I don't want to filter by realtive date. 

Allright, does something like this work for you?

NickolajJessen_0-1654173919996.png

 

Gave me the following error:

 

Error Message:
MdxScript(Model) (21, 13) Calculation error in measure 'LINEINSPECTIONSTLM_EVW'[CLOSED MTD]: A date column containing duplicate dates was specified in the call to function 'TOTALMTD'. This is not supported.

 

Haha, i don't understand these MTD formulas at all 😂

How about something more lowkey like:

This month = 
CALCULATE(
    DISTINCTCOUNT('Tabel (2)'[Record Number])
    ,FILTER('Calendar', 
        'Calendar'[Date] <= EOMONTH(TODAY(),0)
        && 'Calendar'[Date] >= (EOMONTH(TODAY(),-1)+1)

    )
)

Should give you data between 01-06-2022 and 31-06-2022


This seemed to work, thanks. Now I want to add YTD, struglling to understand the difference between EOMONTH and ENDOFMONTH, and the is no EOYEAR. 

Hi @loodle,

 

Very happy that your problem was solved. Please mark it as a solution.
About YTD, you can recreate a post so that you can get better help.

 

EOMONTH

  • Specify a start date. Before or after a few months and return the last day of the month. for example a table with date column from 1/1/2022 to 1/13/2022, 1 month after 1/1/2022, result of EOMONTH is 2/28/2022.

 

ENDOFMONTH 

  • get the last date of current context. for example a table with date column from 1/1/2022 to 1/13/2022, then ENDOFMONTH() return 1/13/2022 rather than 1/31/2022

 

Best Regards

Community Support Team _ chenwu zhu

 

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

amitchandak
Super User
Super User

@loodle , Create a date table join with the Repair date

 

CALCULATE(DISTINCTCOUNT (Table[RECORDNUMBER]),DATESMTD('Date'[Date]), not(isblank(Table[Repair Date])) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I joined the date table to the record table by a one to many relationship on the the Repair Date. I am getting a count now, but it is not the correct number if I verify by filtering my data to repair dates of June 2022. Am I missing TODAY somewhere or does DATESMTD already know that?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.