Forum Discussion
Diego_Vialle
4 years agoHelper 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?
- Anonymous4 years ago
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 _resultBest Regards,
Gao
Community Support TeamIf 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
Anonymous
4 years agoNot 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