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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-stephen-msft
Community Support
Community Support

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
v-stephen-msft
Community Support
Community Support

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors