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
Selded
Helper III
Helper III

MTD measure and Date Filters

All, 

Please i have a MTD measure that works fine. I have included this measure in a table visualization. i have a date slicer on my report page. 

I want the MTD measure figures to remain unchanged if i apply the date filter.

example if my date slicer is for 1st - 18th June, MTD should display values for June 1st to June 28th.

 

Can this be done, or i am missing something.

Below are my snips.

 

Selded_0-1593439634156.png

MTD measure = 

MTD2 = Calculate([MeasureName],DATESMTD(CalendarTable[Date]))

 

Thanks for your hepl. really appreciate.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

// If you keep the upper bound in your
// selection of dates constant, it does
// not matter what lower bound you select,
// the measure MTD2 will always be the same.
// This is due to how DATESMTD works. If,
// however, the measure changes, it means
// you're not doing something correctly.
// For instance, CalendarTable should be marked
// as the Date table in the model. Please check
// dax.guide/datesmtd to understand how the
// function works. Since the documentation states
// that the function is equivalent to this:
//
//DATESBETWEEN (
//    <Dates>,
//    STARTOFMONTH ( LASTDATE ( <Dates> ) ),
//    LASTDATE ( <Dates> )
//)
//
// it's easy to see that in the calculation
// only the last date, upper bound, plays a role
// (see the dependence only on LASTDATE).
// In a word, the measure below should work
// correctly in the sense that its value does not
// depend on the lower bound of the selection made
// in CalendarTable[Date].

MTD2 =
CALCULATE(
    [MeasureName],
    DATESMTD( CalendarTable[Date] )
)

 

Best

D

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@Selded,

This problem does not have a clear answer because the description is not clear. The fact is that if you change the upper bound of your date range, the measure will always change because it's tied to the calendar. Of course, upper bounds used by a measure can be any functions of the current selection of the dates in the calendar but you have not stated what the upper bound for the measure should really be when you change your selections in the slicer.

Best
D

@Anonymous 

 

Thanks for the reply, i have maintained my upper bound at today -1 with the lower bound filtering to any data within the current month.

 

With this, the MTD is working fine, but the moment i change the lower bound, MTD changes.

 

Selded_0-1593443487144.png

 

 

Anonymous
Not applicable

// If you keep the upper bound in your
// selection of dates constant, it does
// not matter what lower bound you select,
// the measure MTD2 will always be the same.
// This is due to how DATESMTD works. If,
// however, the measure changes, it means
// you're not doing something correctly.
// For instance, CalendarTable should be marked
// as the Date table in the model. Please check
// dax.guide/datesmtd to understand how the
// function works. Since the documentation states
// that the function is equivalent to this:
//
//DATESBETWEEN (
//    <Dates>,
//    STARTOFMONTH ( LASTDATE ( <Dates> ) ),
//    LASTDATE ( <Dates> )
//)
//
// it's easy to see that in the calculation
// only the last date, upper bound, plays a role
// (see the dependence only on LASTDATE).
// In a word, the measure below should work
// correctly in the sense that its value does not
// depend on the lower bound of the selection made
// in CalendarTable[Date].

MTD2 =
CALCULATE(
    [MeasureName],
    DATESMTD( CalendarTable[Date] )
)

 

Best

D

Pragati11
Super User
Super User

Hi @Selded ,

 

Try to modify your measure as follows:

MTD2 = Calculate([MeasureName], FILTER(ALL('YOUR TABLENAME'), DATESMTD(CalendarTable[Date])))

Replace 'YOUR TABLENAME' in above dax with your table-name.

 

Thanks,

Pragati 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

@Pragati11 ,

 

I tried the above measure and my visualizations couldnt display.  I replaced table name with my facts table name as indicated.

 

Selded_0-1593442425641.pngSelded_1-1593442446579.png

 

Anonymous
Not applicable

Hi @Pragati11 

 

Would you please explain to me how is this code taken from your formula

FILTER(ALL('YOUR TABLENAME'), DATESMTD(CalendarTable[Date]))

 going to work?

 

As far as the documentation for FILTER goes, the second argument must be a BOOLEAN expression that's calculated for each of the rows of the first argument. The second argument, though, is a table in your FILTER, not a bool expression.

 

Thanks.

 

Best

D

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.

Top Solution Authors