Forum Discussion
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.
- Anonymous2 years ago
Hi Anonymous ,
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
- audreygerredSuper 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.
- AnonymousNot applicable
Hi Anonymous ,
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.