cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
answeriver Regular Visitor
Regular Visitor

DatesMTD explain

Hi,

Please give me explain of this measure.

SALES LAST MONTH = CALCULATE([MLN ST];DATESMTD('Calendar'[Date])) when i use this measure in bars visualisation and add axis product i have right result. But when i add this measure in the table, results is blank.
Actualy i want use this measure in Gauge, so receieve blank, why?
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: DatesMTD explain

hi, @answeriver

First, I will show how to use filter to get the result like DatesMTD.

It corresponds to a filter over the date column using FILTER called by CALCULATETABLE, such as in the following code:

CALCULATETABLE (
    FILTER (
        ALL ( 'Date'[Date] ),
        AND (
            'Date'[Date] <= MAX ( 'Date'[Date] ),
            YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
                && MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Date'[Date] ) )
        )
    )
)

Second, I will explain why it returns blank.

For DatesMTD is a Time-intelligence function, and your date table still has other dates.

So it will keep calculating, so in the next month it returns blank value. and the result of Gauge is the result based on the whole table.

 

Therefore you have two ways to solve it.

1. use a date slicer to filter the date within dates that have data.

2. use the formula to create the Calendar table

Calendar = CALENDAR("2018-01-01",MAX(Table2[Date]))

 

And I recommend the first method.

 

 

Best Regards,

Lin

 

 

 

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

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: DatesMTD explain

hi, @answeriver

First, I will show how to use filter to get the result like DatesMTD.

It corresponds to a filter over the date column using FILTER called by CALCULATETABLE, such as in the following code:

CALCULATETABLE (
    FILTER (
        ALL ( 'Date'[Date] ),
        AND (
            'Date'[Date] <= MAX ( 'Date'[Date] ),
            YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) )
                && MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Date'[Date] ) )
        )
    )
)

Second, I will explain why it returns blank.

For DatesMTD is a Time-intelligence function, and your date table still has other dates.

So it will keep calculating, so in the next month it returns blank value. and the result of Gauge is the result based on the whole table.

 

Therefore you have two ways to solve it.

1. use a date slicer to filter the date within dates that have data.

2. use the formula to create the Calendar table

Calendar = CALENDAR("2018-01-01",MAX(Table2[Date]))

 

And I recommend the first method.

 

 

Best Regards,

Lin

 

 

 

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

View solution in original post

answeriver Regular Visitor
Regular Visitor

Re: DatesMTD explain

Lin hello,

Thank you very much! I understood.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 314 members 3,011 guests
Please welcome our newest community members: