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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.