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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
kdc02
Frequent Visitor

Merging two tables with joining key being between two timestamps

Hi, I have two tables that I want to merge / do a full outer join with using ID as the first joining key and if timestamp is between start time (datetime) and end time (datetime).

 

In SQL, it will be like

a.*, b.*

from a

full outer join b

on a.id = b.id and a.time between b.start_time and b.end_time

 

Is there a way to do this in Power BI?

 

Thank you!

 

 

3 REPLIES 3
danextian
Super User
Super User

hI @kdc02 ,

 

You can do a full outer join in Power Query. After expanding  the merge column, you can then create a conditional columnthat based on your timestamp logic.  Here's how to do a full outer join: https://learn.microsoft.com/en-us/power-query/merge-queries-full-outer.  

Alternatively, you can use a SQL command when you connect to a database:

danextian_0-1700709845517.png

Proposed solution is based on information provided. If this doesn't work for you, please post a usable  (not an image, eg:  table1, table2) sample data that covers your use case and your expected result using that sample data.

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian,

 

My source 1 is data from Sharepoint so I couldn't really use SQL to join them together. I've also tried creating a new column that flags based on the filters I wanted after doing a full outer merge but it just removes the rows and not really joining them together like it would on SQL.

 

Is there another way to do this?

As mentioned please post a sample data.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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