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
Anonymous
Not applicable

joining tables on multiple columns

I have two tables , one for transacational data and one for transport costs. 

 

I want to merge them on a common "Order Number".

However , due to data issues, the Order Number maybe be contained in either a column called "Order Number" or a column called "Reference" in transport costs.

 

This is the same in transactional data.

 

I want to know if there is a way to merge the two tables, so that if we were to call the columns in Transports Costs A & B, and the column in Transactional Data C & D, that I could create a merge where BI would search A in C, then A in D, then B in C then B in D, and if ANY of these are true then to inner join the rest of the data.

 

Here is my example:

 

GL CODEDATECONSIGNMENT/REFERENCEORDER NUMBERCHARGEFUELSUBTOTALGSTTOTALCARRIER  
3800 0000 1190 100014/01/2018I34398225540097201802 $                   38.00 $           2.70 $           40.70 $             4.07 $                                           44.77MAIN100 ChemCouriers - Mainfreight

 

Transaction TypeExp & Cust Sales QtyExp & Cust Sales ValStock On HandTransactionReference 1Reference 2
GRI36047.61679544737954058T692507

 

In this example, I would want BI to search "ORDER NUMBER" in both "Reference 1" and "Reference 2", and then to search "CONSIGNMENT/REFERENCE" in both "Reference 1" and "Reference 2", and if any of these are TRUE then to merge that row, and otherwise to leave it blank. The hiearchy would be Order Number first then if it can't find a match to search through Consignment/Reference second.

 

Thanks for your time.

 

 

 

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

You could create a calculated table with below DAX to merge these two tables.

merge table =
FILTER (
    ADDCOLUMNS (
        CROSSJOIN ( transacational, 'Transports Costs' ),
        "Check1", IF (
            [ORDER NUMBER] = transacational[Reference 1],
            1,
            IF (
                'Transports Costs'[ORDER NUMBER] = transacational[Reference 2],
                1,
                IF (
                    'Transports Costs'[CONSIGNMENT/REFERENCE] = transacational[Reference 1],
                    1,
                    IF (
                        'Transports Costs'[CONSIGNMENT/REFERENCE] = transacational[Reference 2],
                        1,
                        0
                    )
                )
            )
        )
    ),
    [Check1] = 1
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-yulgu-msft

 

When I try to run this, I end up getting a "Working On It" for far longer than this should take - while I can do a single Merge Query in 3 minutes, this one has been running for 2 hours and still isn't completed. Is this normal?

This has been up for 2 hours.This has been up for 2 hours.

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.