Forum Discussion
Lookup values from one table based on calculated result from another table
- 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:
You can simplify it at least in 2 aspects,
- Keep Min only as threshold for each grade bucket;
- Use single-direction filtering in *:* relation (in spite of best practice of 1:*)
For fun only, a showcase of power Excel formulas, (the score in red is to verify the fomula)