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! Learn more

Reply
Diego_Vialle
Helper II
Helper II

DAX - Counting a specific day between dates

I have two date columns in a table, "Start Date" and "End Date". I would like to count how many Mondays there are in this range.

 

@tamerj1  , do you have any idea how to solve it?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Diego_Vialle ,

 

Try this.

count of monday =
VAR _weekdayofstartdate =
    WEEKDAY ( 'Table'[Start Date], 2 )
VAR _weekdayofenddate =
    WEEKDAY ( 'Table'[End Date], 2 )
VAR _weeks_1 =
    IF ( _weekdayofstartdate > _weekdayofenddate || _weekdayofstartdate = 1, 1, 0 )
VAR _days =
    DATEDIFF ( 'Table'[Start Date], 'Table'[End Date], DAY )
VAR _weeks_2 =
    INT ( DIVIDE ( _days, 7 ) )
VAR _result = _weeks_1 + _weeks_2
RETURN
    _result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Diego_Vialle ,

 

Try this.

count of monday =
VAR _weekdayofstartdate =
    WEEKDAY ( 'Table'[Start Date], 2 )
VAR _weekdayofenddate =
    WEEKDAY ( 'Table'[End Date], 2 )
VAR _weeks_1 =
    IF ( _weekdayofstartdate > _weekdayofenddate || _weekdayofstartdate = 1, 1, 0 )
VAR _days =
    DATEDIFF ( 'Table'[Start Date], 'Table'[End Date], DAY )
VAR _weeks_2 =
    INT ( DIVIDE ( _days, 7 ) )
VAR _result = _weeks_1 + _weeks_2
RETURN
    _result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

tamerj1
Super User
Super User

@Diego_Vialle 

yes have some ideas. Can you join now a meeting or it is too late already?

ribisht17
Super User
Super User

  @Diego_Vialle 

Here is the solution >> Counting working days in DAX - SQLBI

 

You need to make slight changes here

 

'Date'[IsWorkingDay] = WEEKDAY( 'Date'[Date] ) IN { 2}

 

Mondays_Count =
CALCULATE(
COUNTROWS ( 'Calendar Table'),
DATESBETWEEN ( 'Calendar Table'[Date], orders_[Order Date], orders_[Ship Date]-1 ),
'Calendar Table'[IsMonday] = TRUE,
ALL ( orders_ )
)

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

@Diego_Vialle

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.