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

NATURALINNERJOIN function doesn't work matching a text column

Hi,

in a my pbi model I need to create a new table by DAX to match some columns of two tables created after more power query logics.

In order to accomplish a such task I've used the NATURALINNERJOIN function but unsuccessfully because I've obtained a cartesian product.

I've analyzed my data inside a bit test model and I've noticed that the issue is caused by the unmatching respect to a text column used in the join function. In particular, in the test model I've created manually two tables:

- Tab_A, with the text column named "Code" and an integer column named "obs_value",

- Tab_B, with the text column named "Code" and an integer column named "exp_value".

I've filled the column "Code" of these two tables with a sample value, "aaaa", adding 2 rows for Tab_A and 3 rows for Tab_B.
No relationships exist between Tab_A and Tab_B.

To create the new dax table I've used this function:

TAB_B_A_JOIN =
NATURALINNERJOIN
( SELECTCOLUMNS(Tab_B,
"Code", Tab_B[Code]&"",
"Expected value", Tab_B[exp_value]+0 ),
SELECTCOLUMNS(Tab_A,
"Code", Tab_A[Code]&"",
"Observed value", Tab_A[obs_value]+0 )
)

but it has returned 6 rows and not 2 ones.
With an integer column as a matching column, the above dax expression functions with success!

I think to use a whatever transformation to obtain a numeric value from the text column, but I don't know a such dax function.

Other suggests to me in order to solve this issue, please? Thanks 🙂

1 ACCEPTED SOLUTION
dedelman_clng
Community Champion
Community Champion

Hi @Anonymous -

 

I cannot replicate your results. Perhaps I don't have the correct data in Tab_A and Tab_B?

 

Tab_A

Codeobs_value

aaaa 1
bbbb 2

 

Tab_B

Codeexp_value

aaaa 3
bbbb 4
cccc 5

 

TAB_B_A_JOIN (copied your code directly from the post)

CodeExpected valueObserved value

aaaa 3 1
bbbb 4 2

 

If that is not the correct source data, please clarify.  Perhaps there are relationships you're not aware of that may be affecting your results?

 

Hope this helps

David

View solution in original post

2 REPLIES 2
dedelman_clng
Community Champion
Community Champion

Hi @Anonymous -

 

I cannot replicate your results. Perhaps I don't have the correct data in Tab_A and Tab_B?

 

Tab_A

Codeobs_value

aaaa 1
bbbb 2

 

Tab_B

Codeexp_value

aaaa 3
bbbb 4
cccc 5

 

TAB_B_A_JOIN (copied your code directly from the post)

CodeExpected valueObserved value

aaaa 3 1
bbbb 4 2

 

If that is not the correct source data, please clarify.  Perhaps there are relationships you're not aware of that may be affecting your results?

 

Hope this helps

David

Anonymous
Not applicable

Hi, thanks for your reply.

I've discovered some errors in data for Tab_A and Tab_B, sorry.

It seems that the NATURALINNERJOIN functions rightly as you have indicated.

Many thanks and bye

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.