Forum Discussion

BILearner's avatar
BILearner
Advocate I
9 years ago
Solved

Calculated Column based on two column in the Same table

Hi,   I have a data similar to attached screenshot. And I am trying to calculate  the Weighted Score column based on Subject Name and test Score columns.   The weighted column is calculated...
  • mattbrice's avatar
    9 years ago

    As a calculated column you could do this:

     

    =SWITCH( TRUE(), 
    Table[Subject Name] = "Math" && isblank( Table[Test Score] ), BLANK(),
    Table[Subject Name] = "Math" && Table[Test Score] >= 90, "4.0",
    Table[Subject Name] = "Math" && Table[Test Score] >=80 && Table[Test Score] <90,"3.5", 
    Table[Subject Name] = "Math" && Table[Test Score] >=70 && Table[Test Score] <80, "3.0",
    .
    .
    Table[Subject Name] = "Science" && isblank( Table[Test Score] ), BLANK(),
    Table[Subject Name] = "Science" && Table[Test Score] >= 75, "4.0",
    Table[Subject Name] = "Science" && Table[Test Score] >= 70 && Table[Test Score] < 75,"3.5", 
    .
    .
    )

    Obvioulsy I didn't fill out the whole thing, but you get the idea.  If you have a duplicative weighted schedule, you could "OR" the Subject Name checks in the SWITCH so as to not have to do a row for every subject.   Keep in mind the SWITCH will stop at the first TRUE statement.

     

    Another approach would be to have nested SWITCH statements,  Outer switches on subject name, inner by score range.