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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ArvindJha
Helper I
Helper I

Create a single table many to many relationship using DAX

Hi all,

 

I want to create single table out of two tables with many to many relationship using DAX , LOOKUP and RELATED does not work.

For time being i have created relationship between them but it does not solve all my problems

PERSONVISITWEIGHT
AVisit1100
AVisit290
AVisit380
BVisit180
BVisit270
BVisit360
   
PERSONHEIGHT
A140
A139
B142

 

Thanks,

Arvind

12 REPLIES 12
olgad
Super User
Super User

@ArvindJha 

FILTER(
CROSSJOIN('Visits', 'Height'),
'Visits'[PERSON] = 'Height'[PERSON]
)


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Hi Olgad , thanks for the response , it gives the below message

The Column with the name of 'PERSON' already exists in the 'Table' Table.

It is because PERSON is present in both tables?

Yes, please rename it first and check if it works, are there any other columns with the same name in both tables? In this case they will give you the same problem.

When we do selectcolumns, we specifically say which columns to take, but when not, there cannot be the columns with the same name. In Power Query such columns will automatically get Person.1 name


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
olgad
Super User
Super User

Try this, but this is inner join

 

CombinedTable =
NATURALINNERJOIN('Visits', 'Height')


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Hi Olgad , thanks for response , it doesn't work 

ArvindJha_0-1735053277160.png

 

Person shall be the common column, check if it is the same datatype sometimes when one is string/text and the other is 'any' or different spelling person Person or there is a space in the name of one then it doesnt work


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

The name and datatype both are same , the 1st solution of CROSSJOIN works the only challenge is i have 30+columns and i need to enter 30 rows for that , is there any alternative to writing 30 rows?

Kedar_Pande
Community Champion
Community Champion

@ArvindJha 

Create a New Table

CombinedTable =
SUMMARIZE(
'VISIT_TABLE',
'VISIT_TABLE'[PERSON],
'VISIT_TABLE'[VISIT],
'VISIT_TABLE'[WEIGHT],
"HEIGHT",
CALCULATE(
MAX('HEIGHT_TABLE'[HEIGHT]),
TREATAS(
VALUES('VISIT_TABLE'[PERSON]),
'HEIGHT_TABLE'[PERSON]
)
)
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Thanks for the response Kedar , output is as below , it takes only the max height 140 and ignores 139 for Person A which is not the expected outcome

ArvindJha_0-1735044984659.png

 

olgad
Super User
Super User

Cant you just merge them in the Power Query? full outer join? 

Or alternatevely,

CombinedTable =
SELECTCOLUMNS(
FILTER(
CROSSJOIN('Visits', 'Height'),
'Visits'[PERSON] = 'Height'[PERSON]
),
"PERSON", 'Visits'[PERSON],
"VISIT", 'Visits'[VISIT],
"WEIGHT", 'Visits'[WEIGHT],
"HEIGHT", 'Height'[HEIGHT]
)

 

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Hello Olgad , it works i needed one input , here i just shared sample data with only 4 columns but in reality i have 20+ columns , so do i need to write 20 lines (one for each column) or is there a way it takes all columns automatically using * or something that would be helphul in such scenarios

Hello Olgad , thanks for the response also to your question on join why i am not taking join is that there are some transformations which is making m-query very slow so i doing them in DAX which is fast and then unable to move back to m-query as those newly created tables using DAX are not visible in m-query

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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