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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
techiebee
Frequent Visitor

Specify custom month for DATESMTD function in DAX

Hello,

 

Can we mention any random month name in DATESMTD function for which we can calculate total sales?

 

Please suggest.

Thanks in Advance.

5 REPLIES 5
Baskar
Resident Rockstar
Resident Rockstar

 

Ya we can add , Try like this it will help u i hope so,

 

 

Measure  =   CALCULATE(Sum (Sales), DATESMTD(DATEADD(calender[Date],2,MONTH))))

 

Try this, here i was added two more month in my Current date.

1.JPG

 

 

 

 

Thanks Baskar, for the example.

 

Measure  =   CALCULATE(Sum (Sales), DATESMTD(DATEADD(calender[Date],2,MONTH))))

 

But I need to mention any random month name. Here, we see that it is adding 2 months to the current month.

And while calculation, I wouldn't be knowing the relevance i.e. how many months it is before or after current month.

 

e.g. User selects May 2016 and that should be passed in the DAX to calculate total sales in May.

 

Please suggest.

Cool dude,

 

 

see basically dax work with your case only.

 

If u select "MOnthname " in slicer it will show only may month sales know ?

 

Calculate(Sum(Sales))

 

Okay thanks.

 

Just another question:

 

Will DATESYTD function work in the same way?

I mean if I select May in slicer, then will that give total starting from current fiscal year till May only?


@techiebee wrote:

Okay thanks.

 

Just another question:

 

Will DATESYTD function work in the same way?

I mean if I select May in slicer, then will that give total starting from current fiscal year till May only?


Slicer is not working that way, though you can use an expression like MAX(dateUsedInSlicer) to get a selected date though. What is the point of the "random" month? You could specify a date range in the slicer and the DATESYTD would work accordingly.
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.