Search code examples
google-sheetsgoogle-sheets-formula

Conditional and ifs + prefix/suffix


I have something like this:

Conditional and pre

In each E cell, I would like to return the D number of that row, as long as certain conditions are fulfilled, with the prefix $ if C2=$, and suffix € if C2=€.

I have this but it's not working at all (despite it is wrong, it probably can help you understand what I need):

=IF(A2="","",IFS(if(C2="$",OR(B2="Buy",B2="Sell"),"$"&D2,if(C2="€",OR(B2="Buy",B2="Sell"),D2&"€"))))

I'm sorry if I just posted something really awful, I tried...

Thanks!


Solution

  • For cell E2 you can use:

    =IF(AND(A2<>"",OR(B2="Buy",B2="Sell")),SWITCH(C2,"$",C2&D2,"€",D2&C2,""),"")
    

    And drag / copy-paste the formula to the remaining rows:

    enter image description here