How to get multiple outputs from a single if function

I have 5 inputs that I need to output as a string of text in a single cell and I cannot figure out how to get it.
The 5 input cells will all read either “0” or “1”. So for example:
Cell C15: 1, D15: 0, E15: 0, F15: 1, G15: 1
Then I need the output either a “x” or a “o” for each of those inputs but in 1 cell. So for example:
Cell C20: oxxoo to match the inputs.

I tried doing this with the if function but could figure it out. I currently have 5 nested ifs that only return a single value.

=IF(C15=1, "o", IF(D15=1, "o", IF(E15=1, "o", IF(F15=1, "o", IF(G15=1, "o", "x")))))

and the output is o

The solution does not need to be an if function, if there is a better function to use please let me know.
Thank you.

1 Like

So you could do something like =IF(C15=1;"o";"x")&IF(E15=1;"o";"x")&IF(E15=1;"o";"x")&IF(F15=1;"o";"x")&IF(G15=1;"o";"x")


Another way could be =SUBSTITUTE(SUBSTITUTE(C15&D15&E15&F15&G15;"1";"o");"0";"x")


but given the inputs are only 1 or 0 then there could be a simpler solution which I am not clever enough to see.

3 Likes

=IF(C15;“o”;“x”)&IF(D15;“o”;“x”)&IF(E15;“o”;“x”)&IF(F15;“o”;“x”)&IF(G15;“o”;“x”)

2 Likes

Not simpler, but other ways to do:

Instead of several operator & you can use function CONCAT and use a cell range. Because of the cell range in IF, the formula has to be entered as array-function, that is, finish input with Ctrl+Shift+Enter. Formula could be
=CONCAT(IF(C15:G15;"o";"x"))
Also TEXTJOIN function is possible, however it is more complex.
=TEXTJOIN("";TRUE();IF(C15:G15;"o";"x"))
The variants with SUBSTITUTE can be entered as normal function
=SUBSTITUTE(SUBSTITUTE(CONCAT(C15:G15);1;"o");0;"x")
=SUBSTITUTE(SUBSTITUTE(TEXTJOIN("";TRUE();C15:G15);1;"o");0;"x"))

Instead of IF function, the CHOOSE function is here also possible. Its choose starts with 1, therefore +1.This example needs input as array-function.
=CONCAT(CHOOSE(C15:G15+1;"x";"o"))
However, I think using IF is better to understand.

6 Likes

=CONCAT(IF(C15:G15=1,"o","x")). See comments below.

1=TRUE anyway so your and my =1 is redundant

1 Like

Yes.
Now I see, that I pasted the formula (and that gives o), choosed Cell Edit Mode (F2), and pressed Ctrl+Shift+Enter (to be entered as array-function). But that also gives o, because if there are no changes in the cell content, Ctrl+Shift+Enter would do nothing.

You might get well shaped and not too much specialized answers if you told for what reason you think to need the output of a compound into one cell.
What if next time your original data might also allow the values 2 and 3?
What if you or somebody wants to get the original values back from the compounds?
= =
See relatedTo_disask_131652_flexible.ods (22.9 KB)

1 Like