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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.