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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
BalazsNy
Helper I
Helper I

Create relation based on condition

Dear All,

I have 2 tables, which I like to connect to each other.

First is a manager list table, including manager name / department / start & end date of belonging to that certain department.

2nd table is for feedbacks, with the date (of submission) / Manager name / rate / comment / category & employee ID.

Screenshot 2024-12-04 120905.png

I want to create a report with a slicer to be able to filter feedbacks by Departments. Therefore, I need to create a relationship between these tables via Manager name column, but it should also check when the feedback is submitted because a manager can be relocated between the departments by the time (see start / end date).

Do you have any idea, how to solve this issue & how relationship between tables should look like.

 

Thank you in advance.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @BalazsNy ,

 

Do you want to have a visualization or a column on your model?

 

You can use the following code for a column on the feedback table:

	MAXX(
		CROSSJOIN(
			FILTER(
				Managers,
				Managers[Start Date] <= 'Feedback list'[Date] && Managers[End Date] >= 'Feedback list'[Date] && Managers[Manager Name] = 'Feedback list'[Manager]
			),
			'Feedback list'
		),
		Managers[Department]
	)

MFelix_1-1733311779978.png

 

If you want a measure just try the following code:

 

Department= 
        MAXX(
			CROSSJOIN(
				FILTER(
					Managers,
					Managers[Start Date] <= MAX('Feedback list'[Date]) && Managers[End Date] >= MAX('Feedback list'[Date]) && Managers[Manager Name] = MAX('Feedback list'[Manager])
				),
				'Feedback list'
			),
			Managers[Department]
		)

MFelix_0-1733311748041.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @BalazsNy ,

 

Do you want to have a visualization or a column on your model?

 

You can use the following code for a column on the feedback table:

	MAXX(
		CROSSJOIN(
			FILTER(
				Managers,
				Managers[Start Date] <= 'Feedback list'[Date] && Managers[End Date] >= 'Feedback list'[Date] && Managers[Manager Name] = 'Feedback list'[Manager]
			),
			'Feedback list'
		),
		Managers[Department]
	)

MFelix_1-1733311779978.png

 

If you want a measure just try the following code:

 

Department= 
        MAXX(
			CROSSJOIN(
				FILTER(
					Managers,
					Managers[Start Date] <= MAX('Feedback list'[Date]) && Managers[End Date] >= MAX('Feedback list'[Date]) && Managers[Manager Name] = MAX('Feedback list'[Manager])
				),
				'Feedback list'
			),
			Managers[Department]
		)

MFelix_0-1733311748041.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.