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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AAAbbbnewbie
Frequent Visitor

DAX for custom start date and end date

Hi Experts, i would need DAX formula to determine the month for the date with custom start date and end date.

Start date is every 21st of the previous month and end date is every 20th of the current month.

For example, 21 Feb 2023 to 20 Mar 2023 is Mar 2023.

 

Also i need MTD showing based on the custom start and end date too. Possible to exclude weekend and Public holiday? i have a calendar for these. 

 

Please help 🙂

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope you can add more columns into the calendar table, like weekdays or some others.

Jihwan_Kim_0-1685168724567.pngJihwan_Kim_1-1685168735651.png

 

Jihwan_Kim_2-1685169043555.png

 

Quantity MTD: = 
CALCULATE (
    [Quantity:],
    WINDOW (
        1,
        ABS,
        0,
        REL,
        ALL ( 'Calendar'[Custom Year-Month], 'Calendar'[Date] ),
        ORDERBY ( [Date], ASC ),
        KEEP,
        PARTITIONBY ( 'Calendar'[Custom Year-Month] ),
        MATCHBY('Calendar'[Date])
    )
)

 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks Jihwan. The calendar table is very useful for me. But i dont understand the second part MTD. What does quantity stand for? 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.