Case statement with multiple field conditions

Hi - I'm looking for a Case statement that will provide multiple conditions and multiple "then" statements but keep getting an error. 

I've tried multiple versions but none have worked. 

 

Examples below:

CASE(`Impact Rank`)
WHEN <(`BDS Rank TW`)THEN CONCAT('<span style="background-color: #00A86B">','OUTPERFORMING')
WHEN =(`BDS Rank TW`)THEN CONCAT('<span style="background-color: #00A86B">','PERFORMING')
ELSE CONCAT('underperforming')
END

 

CASE((`Impact Rank`)
WHEN <(`BDS Rank TW`)
THEN CONCAT('<span style="background-color: #00A86B">','OUTPERFORMING')
WHEN =(`BDS Rank TW`)
THEN CONCAT('<span style="background-color: #00A86B">','PERFORMING')
ELSE CONCAT('underperforming')
END

 

CASE WHEN((`Impact Rank`)<`BDS Rank TW`)
THEN CONCAT('<span style="background-color: #00A86B">','OUTPERFORMING')
ELSE CONCAT('underperforming')
CASE WHEN((`Impact Rank`)=`BDS Rank TW`)
THEN CONCAT('<span style="background-color: #00A86B">','PERFORMING')
ELSE CONCAT('underperforming')
END

Best Answer

  • Property_Ninja
    Accepted Answer

    sorry I had an extra parentheses. Try this ...

     

    CASE
    WHEN `Impact Rank` < `BDS Rank TW`

    THEN CONCAT('<span style="background-color: #00A86B">','OUTPERFORMING')
    WHEN Impact Rank` = `BDS Rank TW`

    THEN CONCAT('<span style="background-color: #00A86B">','PERFORMING')
    ELSE 'UNDERPERFORMING' 

    END

Answers

  • Hello,

     

    Can you try something like this ... 

     

    CASE(
    WHEN `Impact Rank` < `BDS Rank TW`

    THEN CONCAT('<span style="background-color: #00A86B">','OUTPERFORMING')
    WHEN Impact Rank` = `BDS Rank TW`

    THEN CONCAT('<span style="background-color: #00A86B">','PERFORMING')
    ELSE 'UNDERPERFORMING' 

    END

     

    Let me know if this helps,

     

    Brian

  • THANK YOU! 

     

    That worked perfectly.