Forum Discussion

IamTDR's avatar
IamTDR
Icon for Responsive Resident rankResponsive Resident
6 years ago
Solved

Power Query: Date/Time Falls Between Business Hours

Hi I'm struggling to come up with something in power query that will show the following.   I have a records that have a 'Created At' field, which is a date/time field.  I also have a '1st Response...
  • v-kelly-msft's avatar
    6 years ago

    Hi IamTDR

     

    First go to query editor> split columns :Split the date/time columns into 2 columns: date and time,as you see below:

    Then create a calculated column to get the weekday of the field "create at":

     

    Weekday = FORMAT(WEEKDAY('Table (2)'[Create at.1],1),"DDDD")

     

    Finally create 2 measures as below:

     

    is within 2 hours = 
    var a=DATEDIFF(MAX('Table (2)'[Create at.2]),MAX('Table (2)'[the first response.2]),MINUTE)/60 Return
    IF(a<=2,1,0)
    is within business hours = IF(MAX('Table (2)'[Weekday]) in FILTERS('Table'[Weekday ])&&MAX('Table (2)'[Create at.2])>=MAX('Table'[Working hour start ])&&MAX('Table (2)'[the first response.2])<=MAX('Table'[Working hour end]),1,0)

     

    And you will see:

    For the related .pbix file ,pls click here.

     

     
    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!