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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Regular Visitor

## How to Show MTD calculation ?

Dear All,

I have a logic where I have to show data for MTD period.

Sum (Sales)

where Date should be between 1st of the current system/selected month till max date of the selected date/Filter.

Eg:- If current_Date is 07-Feb-2024

Chart should show sales from 01-Feb-2024 till 07-Feb-2024 automatically.

If user select month filter as Jan-2024, then

Chart should show sales from 01-Jan-2024 till 31-Jan-2024.

Thanks in advance.

1 ACCEPTED SOLUTION
Community Support

Hi @kaushi2020 ,

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

``Date = CALENDARAUTO()``

(2) We can create measures.

``````Measure 3 =
var _date=SELECTEDVALUE('Date'[Date])
var _date_start=DATE(YEAR(_date),MONTH(_date),1)
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Date'),'Date'[Date]>=_date_start && 'Date'[Date]<=_date))``````
``````Measure 4 =
var _date=DATE(SELECTEDVALUE('Date'[Date].[Year]),SELECTEDVALUE('Date'[Date].[MonthNo]),1)
var _date_end=EOMONTH(_date,0)
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Date'),'Date'[Date]>=_date && 'Date'[Date]<=_date_end))``````

(3) Then the result is as follows.

Best Regards,

Neeko Tang

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

2 REPLIES 2
Community Support

Hi @kaushi2020 ,

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.

``Date = CALENDARAUTO()``

(2) We can create measures.

``````Measure 3 =
var _date=SELECTEDVALUE('Date'[Date])
var _date_start=DATE(YEAR(_date),MONTH(_date),1)
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Date'),'Date'[Date]>=_date_start && 'Date'[Date]<=_date))``````
``````Measure 4 =
var _date=DATE(SELECTEDVALUE('Date'[Date].[Year]),SELECTEDVALUE('Date'[Date].[MonthNo]),1)
var _date_end=EOMONTH(_date,0)
RETURN CALCULATE(SUM('Sales'[Sales]),FILTER(ALL('Date'),'Date'[Date]>=_date && 'Date'[Date]<=_date_end))``````

(3) Then the result is as follows.

Best Regards,

Neeko Tang

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

Super User

Hello! You can use the TOTALMTD DAX Function to achieve this. You can enter it manual or use quick measures. The below measure assumes you have a measure for Sales and a date table.

Sales MTD =
TOTALMTD([Sales], 'Date'[Date])

 Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

## Helpful resources

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors