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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
CityCat35
Frequent Visitor

Table Relationships & Cross-Filter Directions

I teach both elementary and high school-aged students. I have 3 tables. The first two are the individual grades for each student for each course I teach: 

 ELEM 
SARAH MATH95
BILLYSCIENCE70
BILLYMATH88
SARAH SCIENCE72
SARAH MATH88
BILLYSCIENCE90
BILLYMATH80
SARAH SCIENCE87

 

 HIGH SCHOOL
JASONHISTORY66
MOLLYCALCULUS88
MOLLYHISTORY95
JASONCALCULUS77
JASONHISTORY91
MOLLYCALCULUS70
MOLLYHISTORY90
JASONCALCULUS80

 

The third table is the grade cutpoints for each course.

 GRADESMinMazLetter
ELEMMATH87100A
ELEMMATH7586B
ELEMMATH6274C
ELEMMATH4461D
ELEMMATH043F
ELEMSCIENCE83100A
ELEMSCIENCE7682B
ELEMSCIENCE6681C
ELEMSCIENCE5465D
ELEMSCIENCE053F
HIGH SCHOOLHISTORY85100A
HIGH SCHOOLHISTORY7584B
HIGH SCHOOLHISTORY6274C
HIGH SCHOOLHISTORY4461D
HIGH SCHOOLHISTORY043F
HIGH SCHOOLCALCULUS86100A
HIGH SCHOOLCALCULUS7485B
HIGH SCHOOLCALCULUS6173C
HIGH SCHOOLCALCULUS4260D
HIGH SCHOOLCALCULUS041F

I would like to create a matrix for each group (one for elem and one for high school) that shows the average test results by student/course, and I also want to automatically show the letter grade based on the average results. Thanks to @hnguy71, I created a separate "Courses" table to bridge the grade and score tables. Additionally, the relationship between the High School Student Score table and the new "Courses" table has a cross-filter direction-, but the data displayed for the Elementary Schools students is incorrect. I've been playing around with the relationships for a while, but I can only get one table at a time to filter properly? Any thoughts on how to make this work?

1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Hi @CityCat35 ,

Based on my testing, please try the following methods again:

1.Create the new measure to show the letter grade based on the average results.

elem school Grade = 
VAR _Number = [Elem school average]
RETURN
CALCULATE(MAX('Third Table'[Letter]), _Number >= 'Third Table'[Min] && _Number <= 'Third Table'[Maz] && 'Third Table'[School] = "ELEM")
High school letter = 
VAR _Number = [High school average]
RETURN
CALCULATE(MAX('Third Table'[Letter]), _Number >= 'Third Table'[Min] && _Number <= 'Third Table'[Maz] && 'Third Table'[School] = "HIGH SCHOOL")

2.Drag the measure into the matrix visual.

vjiewumsft_0-1720071970145.png

3.The result is shown below.

vjiewumsft_1-1720072017901.png

 

Best Regards,

Wisdom Wu

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
v-jiewu-msft
Community Support
Community Support

Hi @CityCat35 ,

Based on my testing, please try the following methods again:

1.Create the new measure to show the letter grade based on the average results.

elem school Grade = 
VAR _Number = [Elem school average]
RETURN
CALCULATE(MAX('Third Table'[Letter]), _Number >= 'Third Table'[Min] && _Number <= 'Third Table'[Maz] && 'Third Table'[School] = "ELEM")
High school letter = 
VAR _Number = [High school average]
RETURN
CALCULATE(MAX('Third Table'[Letter]), _Number >= 'Third Table'[Min] && _Number <= 'Third Table'[Maz] && 'Third Table'[School] = "HIGH SCHOOL")

2.Drag the measure into the matrix visual.

vjiewumsft_0-1720071970145.png

3.The result is shown below.

vjiewumsft_1-1720072017901.png

 

Best Regards,

Wisdom Wu

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

tristanbrown
New Member

Hello!

 

I can't diagnose the specific issue you're referring to without more details, plus I'm on a train so can't build it out myself, but I can offer some recommendations that might help you achieve your goals.

 

First, consider re-modeling the data you're working with. To enable effective communication between the three fact tables, you need dimension tables for the columns you're interested in aggregating.

 

Here's a step-by-step approach:

1. **Consolidate Tables**: Combine the "High School" and "ELEM" tables into a single table, which we'll call "FactGrades". Add a new column, "School Type", to designate whether a row is for a High School or Elementary School student. This consolidation will centralize all student grades into one table.

2. **Create Dimension Table**: Create a new table called "DimCourses" with two columns: "School_Type" and "Course_Name". This table will serve as a bridge between your fact tables.

3. **Establish Relationships**: Create two many-to-one relationships:
- One between "FactGrades" and "DimCourses".
- Another between "FactGrades" and "FactCourses" (ensure "FactCourses" includes the letter grade ranges).

These relationships should be based on the "Course_Name" column.

4. **Build Your Matrix**: With both fact tables connected via a single dimension table, you can now populate a matrix with your data. Add a slicer to filter the data by "School_Type" and "Course_Name" from the "DimCourses" table.

5. **Create a Measure for Letter Grades**: Define a measure to associate a letter grade with a student's grade based on specified ranges.

 

DAX:


Letter Grade =
VAR _studentGrade = SELECTEDVALUE(FactStudents[grade])
RETURN
CALCULATE(
MIN(FactCourses[Letter]),
FILTER(
ALL(FactCourses),
_studentGrade > FactCourses[Min_Grade] && _studentGrade <= FactCourses[Max_Grade]
)
)

By adding this measure to your matrix, it will automatically calculate the letter grade regardless of the hierarchy level (by student, course, etc.).

These changes should help streamline your data model and enhance the functionality of your reports.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors