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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
leemsiska
Microsoft Employee
Microsoft Employee

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

leemsiska_0-1631650969646.png

 

 

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
   
  

 

 

leemsiska_1-1631650993711.png

 

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

 

leemsiska_2-1631651027144.png

 

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 3
Anonymous
Not applicable

Hi @leemsiska ,

 

According to your description, I did the following

 

1.Merge two tables

1.png

 

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

2.png

 

3.Add a conditional column named SLA Breach.

3.png

 

Result:

4.png

 

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.

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
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.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors