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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
CalebR
Resolver I
Resolver I

Join/Relationship on table not working as expected due to automatic text trimming

Hello,

I have two tables from two different databases that keep track of our sales orders. My goal is to create a report to see how accurate these databases are to each other but I am running into an interesting issue.

I have joined the tables together on SalesOrderNo but in one database the sales order number is listed as "IA381" meanwhile in the other the same SO# is listed as "00IA381". This is causing the relationship not to work correctly. I want to add a related column in my SO_SalesOrderHeader that grabs the SalesOrderNo from the separate connected database and then I would add another column afterward that compares those two against each other.

So basically it would look like this -

SalesOrderNODATEORDERTYPEGenesisSalesOrderNO (related column)SalesOrdersMatch?
00IA38101/01/2021OIA381YES
00DC04601/18.2022ODC046

YES

This doesnt work now though since the Related() function cant work because it cant find the GenesisSalesOrderNo since 00IA381 doesnt match IA381. Im trying to refrain from automatically trimming the leading zeroes of off the SO# because the true SO# does need those zeroes to be accurate. Im not completely against inserting two 0's in the table from the DB that is trimming them off already but im not sure how to do that so any help would be appreciated.

1 ACCEPTED SOLUTION

My little walkthrough:
I insert both tables, go to table1, insert "New column" (I fix the date column later, not shown here)

andhiii079845_0-1677652103156.png

The function:

SalesOrderShort = right('Table'[SalesOrder],len('Table'[SalesOrder])-2)
 The result:
andhiii079845_8-1677652455139.png
 

 

I create a relationship: Be aware of the right direction depands on your real data. It is not clear in the moment for me. I choose this directions because the on Order misses in the other table

andhiii079845_9-1677652502191.png

 

Then you can check the result:

andhiii079845_10-1677652557695.png

Before going further in the walkthrough. My question is if you have to check also the Date column: 
Are Sales Order and Date column euqal? 





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

Proud to be a Super User!




View solution in original post

8 REPLIES 8
andhiii079845
Super User
Super User

Make please a example for the table how it looks now and how you want to change it. Than its easier to help 🙂





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

Proud to be a Super User!




two tables-

table1 

SalesOrderDate
00IA38101/10/2022
00DC6301/15/2022

table 2

SalesOrderDate
IA38101/10/2022



I expect the following returned in table1 

 

SalesOrderDateIsPresentInTable2?
00IA38101/10/2022YES
00DC6301/15/2022NO

 



My little walkthrough:
I insert both tables, go to table1, insert "New column" (I fix the date column later, not shown here)

andhiii079845_0-1677652103156.png

The function:

SalesOrderShort = right('Table'[SalesOrder],len('Table'[SalesOrder])-2)
 The result:
andhiii079845_8-1677652455139.png
 

 

I create a relationship: Be aware of the right direction depands on your real data. It is not clear in the moment for me. I choose this directions because the on Order misses in the other table

andhiii079845_9-1677652502191.png

 

Then you can check the result:

andhiii079845_10-1677652557695.png

Before going further in the walkthrough. My question is if you have to check also the Date column: 
Are Sales Order and Date column euqal? 





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

Proud to be a Super User!




This makes sense to me! I got it working, no I didnt need to do anything with the date yet hopefully should be good.

 

Thank you for your help!!

andhiii079845
Super User
Super User

Sure, use calculated columns. Than you have both columns. One for join, a other one for showing something in a matrix.





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

Proud to be a Super User!




Im not sure what you mean. Ive tried adding a column using related( Table2[SalesOrderNo] ) but it just returns a blank since the SO#s dont match. What would be the correct way to add a calculated column to table2 where it takes the shortened sales order and adds two leading zeros to it?

andhiii079845
Super User
Super User

What is now the problem, to remove this "00" ? If it alway "00" and not "000" or "0" -> mynewcolumn = right(SalesOrderNo,len(SalesOrderNo)-2))





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

Proud to be a Super User!




Is there a way to alter table2 (the table that is already autotrimming the leading zeroes) to add the zeros back on? And then I can just join table1 00IA381 on to the newly altered table2 IA381 (now 00IA381) value?

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.