Forum Discussion

Amine008's avatar
Amine008
Frequent Visitor
4 years ago
Solved

Calculate DATEDIFF Same column without Weekends

Hi,  Please need help to exlude weekend from dates diff in the same column. The below formula works good for me and return the correct count of days.   Column = VAR temp = TOPN ( 1, FILTER ( 'Cust...
  • AlexisOlson's avatar
    4 years ago

    This is easier if you have a date dimension table so that you can iterate over days and count them like this:

     

    [...]
    RETURN
        COUNTROWS (
            FILTER (
                'Calendar',
                'Calendar'[Date] <= 'Customer visit'[DateOfVisit]
                    && 'Calendar'[Date] > MINX ( temp, [DateOfVisit] )
                    && WEEKDAY ( 'Calendar'[Date] ) IN { 2, 3, 4, 5, 6 }
            )
        )