Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DATEDIFF on single column

I have a table that tracks the history of opportunities through different phases. I am trying to figure out how to create a measure that will tell me the difference in days (excluding weekends) that ...
  • v-alq-msft's avatar
    v-alq-msft
    6 years ago

    Hi, Anonymous 

    It is unavailble to use DateDiff() function if you want to calculate workdays. You can try the following measure which excludes weekends.

     

    Date Diff StageName = 
    COUNTROWS (
            FILTER (
                CALENDAR (
                    CALCULATE (
                        MIN ( 'Opportunity History'[CreateDate] ),
                        ALLEXCEPT ( 'Opportunity History', 'Opportunity History'[StageName] )
                    ),
                    CALCULATE (
                        MAX ( 'Opportunity History'[CreateDate] ),
                        ALLEXCEPT ( 'Opportunity History', 'Opportunity History'[StageName] )
                    )
                ),
                NOT WEEKDAY ( [Date] ) IN { 1, 7 }
                
            )
        )

     

    Result:

     

    Best Regards

    Allan