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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
fr_jc
Advocate I
Advocate I

Measure to Calculate DATEDIFF in Mins over NETWORKDAYS

Hi I have created a simple measure which calcs the total minutes between two dates but what I actaully need to do is calcualte the total minutes between the two dates excluding any Saturday or Sunday that may exist within the period.

It is proabbly simple solution but i just can't seem to get it.  

Anyone know if there is a way I can do a similar calc but for networkdays only?

any help would be greatly appreaciated..

Age Since Created in Mins = 
 VAR _CreatedDateTime = SELECTEDVALUE( Table[Created_Date] )
 VAR _RefreshDateTime = MAX( DBDateTime[DBDateTime] )

RETURN
    DATEDIFF( 
        _CreatedDateTime , 
        _RefreshDateTime ,
        MINUTE
    )

 

1 ACCEPTED SOLUTION
fr_jc
Advocate I
Advocate I

After spending way to much time looking at this today I found I just need to walk away and it came to me.

 

Here is how I resolved it if it may be of any help to anyone else.

 

VAR _CreatedDateTime = SELECTEDVALUE( Table[Created_Date] )
VAR _RefreshDateTime = MAX( DBDateTime[DBDateTime] )
VAR _MinsDiff = 
    DATEDIFF( 
        _CreatedDateTime , 
        _RefreshDateTime ,
        MINUTE
    ) --Total minutes of all datetime from first
VAR _DaysDiff = 
    DATEDIFF( 
        _CreatedDateTime , 
        _RefreshDateTime , 
        DAY
    ) --Total number of all days from first.
VAR _NetworkDaysDiff = NETWORKDAYS( _CreatedDateTime , _RefreshDateTime ) - 1  -- removing first day as network days counts all days I need to calc days from first day.
VAR _WeekendDays = _DaysDiff - _NetworkDaysDiff  -- find the number of weekend days by subtracting network days from all days
VAR _WeekendMins = _WeekendDays * 1440 -- convert days to minutes

RETURN
_MinsDiff - _weekendMins  

 

View solution in original post

1 REPLY 1
fr_jc
Advocate I
Advocate I

After spending way to much time looking at this today I found I just need to walk away and it came to me.

 

Here is how I resolved it if it may be of any help to anyone else.

 

VAR _CreatedDateTime = SELECTEDVALUE( Table[Created_Date] )
VAR _RefreshDateTime = MAX( DBDateTime[DBDateTime] )
VAR _MinsDiff = 
    DATEDIFF( 
        _CreatedDateTime , 
        _RefreshDateTime ,
        MINUTE
    ) --Total minutes of all datetime from first
VAR _DaysDiff = 
    DATEDIFF( 
        _CreatedDateTime , 
        _RefreshDateTime , 
        DAY
    ) --Total number of all days from first.
VAR _NetworkDaysDiff = NETWORKDAYS( _CreatedDateTime , _RefreshDateTime ) - 1  -- removing first day as network days counts all days I need to calc days from first day.
VAR _WeekendDays = _DaysDiff - _NetworkDaysDiff  -- find the number of weekend days by subtracting network days from all days
VAR _WeekendMins = _WeekendDays * 1440 -- convert days to minutes

RETURN
_MinsDiff - _weekendMins  

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.