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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
meghansh
Frequent Visitor

Many to Many relationship

i have 2 tables as Phase and Course. Course has following fields and values

CourseID = 1, phase = basic, start date = 24 aug, 2024, end date = 30 aug 2024

CourseID= 1, phase = intermediate, start date = 1 sept 2024, end date = 30 sept 2024.

CourseID= 1, phase = advanced, start date = 1 oct 2024, end date = 30 oct 2024.

Phase has

Phase ID = 1, CourseID = 1, phase = basic, comment = abc,

Phase ID = 2, CourseID = 1, phase = intermediate, comment = txt,

now as i join these tables in power bi, evidently this create a many to many relationship.

what i need in the report view is a table which says,

CourseID= 1, phase = basic, start date = 24 aug 2024, end date = 30 aug 2024, comment = abc

CourseID= 1, phase = intermediate, start date = 1 sept2024, end date = 30 sept2024, comment = txt.

 

What can i use to achieve this? Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @meghansh 

 

Please try this:

Here's the sample data:

vzhengdxumsft_0-1729564160060.pngvzhengdxumsft_1-1729564168294.png

Then add a calculated table:

Table = 
	SELECTCOLUMNS(
		FILTER(
			CROSSJOIN(
				'Course',
				SELECTCOLUMNS(
					'Phase',
					"_phase", 'Phase'[phase],
					"_CourseID", 'Phase'[CourseID],
					'Phase'[comment]
				)
			),
			'Course'[CourseID] = [_CourseID] && 'Course'[phase] = [_phase]
		),
		'Course'[CourseID],
		'Course'[phase],
		'Course'[start date],
		'Course'[end date],
		'Phase'[comment]
	)

The result is as follow:

vzhengdxumsft_3-1729564249489.png

vzhengdxumsft_4-1729564296153.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @meghansh 

 

Please try this:

Here's the sample data:

vzhengdxumsft_0-1729564160060.pngvzhengdxumsft_1-1729564168294.png

Then add a calculated table:

Table = 
	SELECTCOLUMNS(
		FILTER(
			CROSSJOIN(
				'Course',
				SELECTCOLUMNS(
					'Phase',
					"_phase", 'Phase'[phase],
					"_CourseID", 'Phase'[CourseID],
					'Phase'[comment]
				)
			),
			'Course'[CourseID] = [_CourseID] && 'Course'[phase] = [_phase]
		),
		'Course'[CourseID],
		'Course'[phase],
		'Course'[start date],
		'Course'[end date],
		'Phase'[comment]
	)

The result is as follow:

vzhengdxumsft_3-1729564249489.png

vzhengdxumsft_4-1729564296153.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

your sample data does not demonstrate the need for a many to many relationship.  Provide sample data with more course IDs, for example. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.