SOLVED

Excel (SWITCH function?)

Copper Contributor

I wish to show a description next to a couple of sub-totals (e.g let us say that the sub-totals are in cells G50 & H50). I want the description in, say, cell D50 to show the wording "Profit" or "Loss" depending on whether G50 & H50 are both positive, both negative, or to show Profit/(Loss) if G50 is positive, and H50 is negative - or vice versa.

 

5 Replies

@Nigel_Lewis570202 

=IF(AND(G50>0,H50>0),"Profit",IF(AND(G50<0,H50<0),"Loss",IF(AND(G50>0,H50<0),"Profit/(Loss)",IF(AND(G50<0,H50>0),"(Loss)/Profit",""))))

You can apply nested IF as well. An alternative besides SWITCH could be IFS.

profit loss.JPG 

Danke sehr, Quadruple Pawn. I understand the logic of the nested "IF" statements, but they are more involved than I had hoped. Thanks again for your response.

@Nigel_Lewis570202

Alternatively

 

=IF(G50>0,IF(H50>0,"Profit","Profit/(Loss"),IF(H50>0,"(Loss)/Profit","Loss"))

best response confirmed by Nigel_Lewis570202 (Copper Contributor)
Solution
Hans
Thanks, that looks neat - I will try it!

@Nigel_Lewis570202 

If you want a recent function

= SWITCH(
    SUM((values>0)*{2,1}),
    3, "Profit",
    2, "Profit/(Loss)",
    1, "(Loss)/Profit",
       "(Loss)"
  )
1 best response

Accepted Solutions
best response confirmed by Nigel_Lewis570202 (Copper Contributor)
Solution
Hans
Thanks, that looks neat - I will try it!

View solution in original post