Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
imagine i have these tables:
1. teachers (list of teachers with teacherid, cityid)
2. students (studentid, cityid)
3. scores (studentid, teacherid, score)
4. city (cityid, cityname, state ...)
now if i link scores to teacher and student both, it wont let me keep both the relationship active. as it will ahve two paths from scores to city (scores --> teachers --> city) and (scores --> students --> city). although i dont even have bi-directional relations set up. i am ok with direction being teachers to score and student to score. this seem like a common problem...how would you model to not have this problem?
Solved! Go to Solution.
Hi, @pbipoweruser123
I am glad to help you.
According to your description, or you can consider creating two instances of the city table(New table in Power BI Desktop), one for teachers and one for students. We can call them teacher_city and student_city, respectively:
student_city = city
teacher_city = city
And then modify the relationships:
Join the teachers table to the teacher_city table via cityid.
Join the students table to the student_city table via cityid.
Then create two Measures:
Total Students =
DISTINCTCOUNT ( students[studentid] )
Total Teachers =
DISTINCTCOUNT ( teachers[teacherid] )
Here is the result:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
i simply wanted to put a card that could show total students(count of distint studentid) in a city (city name in slicer), or total number of teachers in a city.
Hi, @pbipoweruser123
I am glad to help you.
According to your description, or you can consider creating two instances of the city table(New table in Power BI Desktop), one for teachers and one for students. We can call them teacher_city and student_city, respectively:
student_city = city
teacher_city = city
And then modify the relationships:
Join the teachers table to the teacher_city table via cityid.
Join the students table to the student_city table via cityid.
Then create two Measures:
Total Students =
DISTINCTCOUNT ( students[studentid] )
Total Teachers =
DISTINCTCOUNT ( teachers[teacherid] )
Here is the result:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
In Power BI, when you have multiple relationships between tables that create a potential circular dependency, you need to carefully manage these relationships to avoid ambiguity and errors. Here’s how you can model your data to handle this scenario:
Create Relationships:
Managing Relationships:
Create the Relationships:
To set a relationship as inactive:
Use DAX to Leverage Inactive Relationships:
Example DAX formula using the inactive relationship:
This formula calculates the total score, using the inactive relationship between Scores and Students for the calculation.
To visualize the relationships:
Active Relationship:
Inactive Relationship:
Data Model Complexity: Be aware that complex relationships can lead to increased complexity in DAX calculations. Ensure that you document these relationships well for easier maintenance and understanding.
Performance: Inactive relationships may affect performance depending on the complexity of your calculations. Monitor performance and optimize as needed.
By setting the appropriate relationships as active or inactive and using DAX functions like USERELATIONSHIP, you can manage and use multiple relationships effectively in Power BI.
User | Count |
---|---|
85 | |
81 | |
64 | |
53 | |
46 |
User | Count |
---|---|
101 | |
49 | |
42 | |
39 | |
38 |