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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Alpha427
Frequent Visitor

Join table with several columns and condition

Hello everyone,

 

I am facing a special case with Power BI Desktop.

Here is the situation, I have two tables with some columns :

 

+--------------+                +--------------+
|                         |                |                        |
|                         |                |                        |
|    TableA           |                |    TableB          |
|                         |                |                        |
|                         |                |                        |
|                         |                |                        |
++-------------+               ++-------------+
 |                                           |
 +---+columnA                    +--+columnA
 |                                           |
 +---|columnB                      +--+columnDate
 |                                           |
 +---|columnC                     +--+column...
 |
 +---+column...

 

 

I want to create a relation between these two tables, with this condition :

 

TableA.columnA = TableB.columnA and TableB.columnDate between TableA.columnB and TableA.columnC

 

 

I am a beginner on Power BI and I have no idea of how to do this..

 

Could you help me ?

 

 

4 REPLIES 4
Alpha427
Frequent Visitor

I didn't find element which could help me in what you sent 😕

 

I have found this topic :

 

https://community.powerbi.com/t5/Desktop/Unable-to-merge-or-join-tables-based-on-condition/m-p/27320...

 

+ this page : https://msdn.microsoft.com/en-us/query-bi/m/table-selectrows

 

So, if I follow them, I should have a formula like this ?

 

Table.SelectRows(TableA, (TableA) => TableA[columnA] = TableB[columnA] and TableB[columnDate] >= TableA[columnB] and TableB[columnDate] <= TableA[columnC])[TableA]

 

I don't have the possibility to test this formula before tomorrow. However, will this only display TableA columns or TableB's too ?

Up

Does someone have an idea ? I'm still searching on the net but I can't find how to join the tables...

 

I'm on an idea currently. The idea is merging the two table (left join), and then apply a filter to fulfill the condition (a date between the two others). I can merge the table via edit queries, but how to apply the filter then ?

v-yuta-msft
Community Support
Community Support

Hi Alpha427,

 

About create and manage relationships in power bi, please refer to this documentation: https://docs.microsoft.com/en-us/power-bi/desktop-create-and-manage-relationships. In addtion, if you want to merge tables in power bi, please refer to this documentation: https://docs.microsoft.com/en-us/power-bi/desktop-shape-and-combine-data#combine-data.

 

Regards,

Jimmy Tao

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.