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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
CityCat35
Frequent Visitor

Lookup values from one table based on calculated result from another table

I have two tables. The first is a list of all the test scores of my students for each class I teach:

 

StudentCourseTest Result
BobbyScience92
SarahMath99
TimEnglish100
BobbyScience86
SarahMath77
TimEnglish80
BobbyScience61
SarahMath60
TimEnglish70

 

Each course has its own grading system. The second table displays the cutpoints used to determine their letter grade.

CourseMinMaxGrade
Science87100A
Science7586B
Science6274C
Science4461D
Science043F
Math83100A
Math7682B
Math8166C
Math5465D
Math053F
English85100A
English7584B
English6274C
English6144D
English043F

 

I'm using a matrix visual to display the average test results by student/course, and I also want to automatically show the letter grade based on the average results--but I'm stuck. Is there a way to find the grade based on the class and average score?

 

1 ACCEPTED SOLUTION
hnguy71
Super User
Super User

Hi @CityCat35 

To bring both data together, you'll most likely would need a third table to bridge the two together. There are more than one grade per course, and there are multiple students per course.

hnguy71_0-1719941775954.png


By the way, your Grade table has some inconsistencies. Min and Max are swapped on some rows.

You'll then link the two together via relationships. Do take note of the cross-filter direction on one line (not needed at the moment but I do suspect you may want to eventually use it down the line for another evaluation)

hnguy71_1-1719941962743.png

 

Create your average test score measure:

 

Course.Avg.Number = AVERAGE(StudentScores[Test Result])

 

 

And then finally in another measure, based on the average, return your grade label:

 

Course.Avg.Grade = 
VAR _Number = [Course.Avg.Number]
RETURN
CALCULATE(MAX(Grading[Grade]), _Number >= Grading[Min] && _Number <= Grading[Max] )

 

 
Your output should look like this:

hnguy71_2-1719942077456.png

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

You can simplify it at least in 2 aspects,

  1. Keep Min only as threshold for each grade bucket;
  2. Use single-direction filtering in *:* relation (in spite of best practice of 1:*)

ThxAlot_0-1719945617762.png  

ThxAlot_4-1719946026708.png

 

ThxAlot_3-1719945897135.png

 

For fun only, a showcase of power Excel formulas, (the score in red is to verify the fomula)

ThxAlot_6-1719946932516.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



hnguy71
Super User
Super User

Hi @CityCat35 

To bring both data together, you'll most likely would need a third table to bridge the two together. There are more than one grade per course, and there are multiple students per course.

hnguy71_0-1719941775954.png


By the way, your Grade table has some inconsistencies. Min and Max are swapped on some rows.

You'll then link the two together via relationships. Do take note of the cross-filter direction on one line (not needed at the moment but I do suspect you may want to eventually use it down the line for another evaluation)

hnguy71_1-1719941962743.png

 

Create your average test score measure:

 

Course.Avg.Number = AVERAGE(StudentScores[Test Result])

 

 

And then finally in another measure, based on the average, return your grade label:

 

Course.Avg.Grade = 
VAR _Number = [Course.Avg.Number]
RETURN
CALCULATE(MAX(Grading[Grade]), _Number >= Grading[Min] && _Number <= Grading[Max] )

 

 
Your output should look like this:

hnguy71_2-1719942077456.png

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.