Forum Discussion

leemsiska's avatar
leemsiska
Microsoft Employee
4 years ago

Merge tables based on date range

Hello, 

 

A bit stuck and confused with the table merge process. I have two tables, Date Range, which has my daily date range of when a job should be executed on a particular day, and with that I have an SLA for that day. Then I have the actual job execution time - start and end time. I would like to merge both tables based on the job name, and the range which that job executed on the day falls under. In the even that the job execution for the day is out of range or did not trigger, I should be able to indicate that in the output table. Possibly merge is not the best solution, I just need to be able to look up the Date Range table with the start time to determine if that job executed on the day, then using End time to compare if that is > than SLA time, then mark it as SLA Breach.

 

Date Range   
Job NameStart Time RangeEnd Time RangeSLA TIME
Batch JOB A9/12/2021 23:309/13/2021 6:309/13/2021 2:30
Batch JOB B9/12/2021 23:309/13/2021 6:309/13/2021 2:30
Batch JOB C9/12/2021 23:309/13/2021 6:309/13/2021 2:30
Batch JOB D9/12/2021 23:309/13/2021 6:309/13/2021 2:30
Batch JOB A9/13/2021 23:309/14/2021 6:309/14/2021 2:30
Batch JOB B9/13/2021 23:309/14/2021 6:309/14/2021 2:30
Batch JOB C9/13/2021 23:309/14/2021 6:309/14/2021 2:30
Batch JOB D9/13/2021 23:309/14/2021 6:309/14/2021 2:30

 

 

Job Execution  
Job NameStart TimeEnd Time 
Batch JOB A9/12/2021 23:599/13/2021 0:32
Batch JOB B9/13/2021 1:259/13/2021 2:45
Batch JOB C9/13/2021 7:309/13/2021 9:32
Batch JOB D9/12/2021 23:479/12/2021 23:53
Batch JOB A9/14/2021 2:319/14/2021 3:12
Batch JOB B9/14/2021 9:309/14/2021 10:01
   
  

 

 

 

Desired results

Job NameStart Time RangeEnd Time RangeSLA TIMEJob NameStart TimeEnd Time SLA BreachJob Not Triggered in Range
Batch JOB A9/12/2021 23:309/13/2021 6:309/13/2021 2:30Batch JOB A9/12/2021 23:599/13/2021 0:32N 
Batch JOB B9/12/2021 23:309/13/2021 6:309/13/2021 2:30Batch JOB B9/13/2021 1:259/13/2021 2:45N 
Batch JOB C9/12/2021 23:309/13/2021 6:309/13/2021 2:30    Y
Batch JOB D9/12/2021 23:309/13/2021 6:309/13/2021 2:30Batch JOB D9/12/2021 23:479/12/2021 23:53N 
Batch JOB A9/13/2021 23:309/14/2021 6:309/14/2021 2:30Batch JOB A9/14/2021 0:319/14/2021 3:12Y 
Batch JOB B9/13/2021 23:309/14/2021 6:309/14/2021 2:30    Y
Batch JOB C9/13/2021 23:309/14/2021 6:309/14/2021 2:30    Y
Batch JOB D9/13/2021 23:309/14/2021 6:309/14/2021 2:30    Y

 

 

Jobs that will not match 

Batch JOB B9/14/2021 9:309/14/2021 10:01
Batch JOB C9/13/2021 7:309/13/2021 9:32

 

I am pulling data from Azure App Insight via a query 

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi leemsiska ,

     

    According to your description, I did the following

     

    1.Merge two tables

     

    2.Add a custom column named Job Not Triggered in Range.

     

    3.Add a conditional column named SLA Breach.

     

    Result:

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • leemsiska's avatar
      leemsiska
      Microsoft Employee

      Hi Anonymous

       

      Thanks for responding to the request for help. I followed your steps and did not quite resolve the issue. Partly this is due to my fault as I did not present the scenario exactly as my actual data set. In the example I shared earlier, this assumes a 1:1 match between the two tables. In actual fact, table on the left (Date Range) has more records than the execution table, as this could be due to the job missing from schedule. My data set has 376 records on left and 151 on right table 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi leemsiska ,

         

        I believe Merge can complete your operation. Merge also has several join types you can choose to try.

        About join types, you can refer to

        Choose the Right Merge Join Type in Power BI

         

        Best Regards,

        Stephen Tao

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.