Forum Discussion

CityCat35's avatar
CityCat35
Frequent Visitor
2 years ago
Solved

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:   Student Course Test Result Bobby Science 92 Sarah Math 99 Tim English 100 ...
  • hnguy71's avatar
    2 years ago

    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.


    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)

     

    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: