Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have sales data from
1-1-2022 to 25-09-2024
Sales Table have the column
invno,invdate,item,qty,Netamount
i have calender table
start date :1-1-2024end date: 31-12-2024
i Calculate MTD
its showing blank( MTD function is showing dec month sales)
but i want to calculate CM MTD
1. IF i didn't filter any month it need to show Curent month MTD
2. IF I select any multiple month it need to show that selected month savel value
Solved! Go to Solution.
Hi @rajasekar_o
Try this:
LYMTD Sales =
VAR _year = SELECTEDVALUE('Calendar'[Year])
VAR _month = VALUES('Calendar'[Month])
RETURN
IF(
ISFILTERED('Calendar'[Year]) && ISFILTERED('Calendar'[Month]),
CALCULATE(
SUM('Sales'[Netamount]),
FILTER(
'Sales',
YEAR('Sales'[invdate]) = _year - 1
&&
MONTH('Sales'[invdate]) IN _month
)
),
TOTALMTD(
SUM('Sales'[Netamount]),
'Sales'[invdate]
)
)
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rajasekar_o
Try this:
LYMTD Sales =
VAR _year = SELECTEDVALUE('Calendar'[Year])
VAR _month = VALUES('Calendar'[Month])
RETURN
IF(
ISFILTERED('Calendar'[Year]) && ISFILTERED('Calendar'[Month]),
CALCULATE(
SUM('Sales'[Netamount]),
FILTER(
'Sales',
YEAR('Sales'[invdate]) = _year - 1
&&
MONTH('Sales'[invdate]) IN _month
)
),
TOTALMTD(
SUM('Sales'[Netamount]),
'Sales'[invdate]
)
)
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @rajasekar_o
Thank you very much 123abc for your prompt reply.
For your question, here is the method I provided:
"Calendar"
Calendar =
ADDCOLUMNS(
CALENDAR(DATE(2024, 1, 1), DATE(2024, 12, 31)),
"Year", YEAR([Date]),
"Month", MONTH([Date]),
"Day", DAY([Date])
)
"Sales"
create a measure.
MTD Sales =
VAR _year = VALUES('Calendar'[Year])
VAR _month = VALUES('Calendar'[Month])
RETURN
IF(
ISFILTERED('Calendar'[Year]) && ISFILTERED('Calendar'[Month]),
CALCULATE(
SUM('Sales'[Netamount]),
FILTER(
'Sales',
YEAR('Sales'[invdate]) in _year
&&
MONTH('Sales'[invdate]) IN _month
)
),
TOTALMTD(
SUM('Sales'[Netamount]),
'Sales'[invdate]
)
)
Here is the result.
No slicer
Selective slicer
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
thank you its working
simmularly how to calculate lastyear mtd
if i select sep month LYMTD need to calculate value
1-9-2023 to 27-9-2023
if i select jan or feb month LYMTD need to calculate value
then need to show full month value
if i select multiple month then show selected month sales from lastyear
To address your requirement for calculating Month-to-Date (MTD) values based on whether a month is selected or not, you can use the following DAX measure in Power BI:
MTD Sales =
VAR SelectedMonth = SELECTEDVALUE('Calendar'[Month], MONTH(TODAY()))
VAR SelectedYear = SELECTEDVALUE('Calendar'[Year], YEAR(TODAY()))
RETURN
CALCULATE(
SUM(SalesTable[Netamount]),
DATESBETWEEN(
'Calendar'[Date],
DATE(SelectedYear, SelectedMonth, 1),
TODAY()
)
)
am using the year filter and month filter only
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!