Max
Max

Reputation: 940

If formula with comma output

How can I make this if formula work?

=IF(J1="b","b","$A1,$B1")

Here if the first condition is false, then the output should be "$A1,$B1". but I get literally $A1,$B1 in this case. Instead, I want the values of A1 and B1 to be output comma separated. E.g: (1,2) How can I fix this, please? Thanks.

Upvotes: 1

Views: 102

Answers (2)

user4039065
user4039065

Reputation:

Try one of these,

=IF(J1="b", "b", $A1&","&$B1)
=IF(J1="b", "b", concatenate($A1, ",", $B1))
=IF(J1="b", "b", TEXTJOIN(",", TRUE, $A1:$B1))

CONCATENATE has been 'grandfathered' out in favor of CONCAT with newer versions but if you have CONCAT then you should have TEXTJOIN which is the better choice.

Upvotes: 5

BigBen
BigBen

Reputation: 50008

You can use & or if you prefer CONCATENATE.

=IF(J1="b","b",A1&","&B1) or =IF(J1="b","b",CONCATENATE(A1,",",B1))

Upvotes: 2

Related Questions