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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ChrisDiener
Regular Visitor

Conditional Merge Query across two tables

I have an On-Hire table that lists all transactions or instances where my customers hire equipment.

e.g. Lawn Mower was hired by Customer 1234 on January 18, 2024 and agrees to return the item on 19 January 2024.

 

I have another table titled Off-Hire that lists all transactions or instances where customers return equipment.

e.g. Lawn Mower was returned by Customer 1234 on 20 January, 2024

 

I am wanting to return a column on the On-Hire table to state if the item has been returned (Yes/No).

The problem is that the only links between both tables that can be used are "Customer Name" and "Hire Item". And over time, this customer will re-hire the same piece of equipment. A simple merge query will fail because of multiple Off-Hire transactions for the same customer and piece of equipment, and as you can see above in bold, the return date does not match the agreed return date on the On-Hire transaction.

 

Is there a way to conditionally search or filter the Off-Hire transaction table to find the most current Off-Hire transaction for that "Customer Name" and "Hire Item"? Fortunatly the way I have built the form which collects the data for this table/report only allows the Hire

 

2024-01-22_19-05-12.jpg

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @ChrisDiener ,

It is assumed that if an object is borrowed, it must be returned.
Try grouping the two tables by [Customer Name] and [Hire Item] and adding an Index column to mark a loan/return.
On-Hire Requests

vcgaomsft_0-1705991718836.png

Off-Hire Requests

vcgaomsft_1-1705991761120.png

Merge:

vcgaomsft_2-1705991794880.png

Expand and filter rows:

vcgaomsft_3-1705991826480.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @ChrisDiener ,

It is assumed that if an object is borrowed, it must be returned.
Try grouping the two tables by [Customer Name] and [Hire Item] and adding an Index column to mark a loan/return.
On-Hire Requests

vcgaomsft_0-1705991718836.png

Off-Hire Requests

vcgaomsft_1-1705991761120.png

Merge:

vcgaomsft_2-1705991794880.png

Expand and filter rows:

vcgaomsft_3-1705991826480.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

ChrisDiener
Regular Visitor

I forgot to mention, and I am unsure if it helps.

The Off-Hire form which I developed only allows the customer to select a "Hire Item" which is currently allocated to them. Therfore, the date which that Off-Hire notification is submitted is (at that time) true.

The problem still remains where a customer has multiple instances where the same item has been hired multiple times. How can I define what hire is still outstanding or complete... Yes/No.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors