Magic ETL

Magic ETL

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

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answer

  • Contributor
    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


    **Please mark "Accept as Solution" if this post solves your problem
    **Say "Thanks" by clicking the "heart" in the post that helped you.

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


    **Please mark "Accept as Solution" if this post solves your problem
    **Say "Thanks" by clicking the "heart" in the post that helped you.
  • Contributor
    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


    **Please mark "Accept as Solution" if this post solves your problem
    **Say "Thanks" by clicking the "heart" in the post that helped you.
  • THANK YOU! 

     

    That worked perfectly.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In