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
kellzp22
Frequent Visitor

Merging Tables with Date Condition

Hi, 

 

I am trying to merge two tables together. The first table is a jobs table, which provides an employee their start time, end time and  location. I'd like to merge this will a bed allocation table, so that if the shift is at the same location and within the allocation date range, then the Job. No. should be allocated to the Bed Allocation table.

 

Jobs Table: 

kellzp22_0-1645592871545.png

Bed Allocation:

kellzp22_0-1645593288473.png

 

 

Bed Allocation (Once Merged):

kellzp22_2-1645592926881.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @kellzp22 ,

 

You can use the Merge fetaure.

Sample data

Jobs:

vstephenmsft_0-1646386070162.png

Bed Allocation:

vstephenmsft_1-1646386078977.png

 

1.Select 'Merge Queries as New', and then set as follows, click OK.

vstephenmsft_2-1646386117755.png

vstephenmsft_3-1646386127509.png

vstephenmsft_5-1646386204682.png

 

2.Expand all columns.

vstephenmsft_4-1646386197171.png

 

3.Add a custom column.

vstephenmsft_6-1646386236216.png

vstephenmsft_7-1646386257039.png

 

 

4.Filter out the rows with a custom column value of 1, then remove unnecessary columns, and the final result.

vstephenmsft_8-1646386272188.png

vstephenmsft_10-1646386340881.png

Result:

vstephenmsft_9-1646386330820.png

 

You can check more details from the attachment.

 

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.

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @kellzp22 ,

 

You can use the Merge fetaure.

Sample data

Jobs:

vstephenmsft_0-1646386070162.png

Bed Allocation:

vstephenmsft_1-1646386078977.png

 

1.Select 'Merge Queries as New', and then set as follows, click OK.

vstephenmsft_2-1646386117755.png

vstephenmsft_3-1646386127509.png

vstephenmsft_5-1646386204682.png

 

2.Expand all columns.

vstephenmsft_4-1646386197171.png

 

3.Add a custom column.

vstephenmsft_6-1646386236216.png

vstephenmsft_7-1646386257039.png

 

 

4.Filter out the rows with a custom column value of 1, then remove unnecessary columns, and the final result.

vstephenmsft_8-1646386272188.png

vstephenmsft_10-1646386340881.png

Result:

vstephenmsft_9-1646386330820.png

 

You can check more details from the attachment.

 

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.

 

 

What if some Locations has no data in Allocation table, they will be filtered, I want to keep the null values?

VijayP
Super User
Super User

@kellzp22 
in the both the Tables you must have similar column (1 column atleast) which is now missing,

So, Create a columns in both Tables with Location & EndDateTime and the try merging based on that column in both the tables to get the result !Share you kudos




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


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.