excelFormulaUtilitiesJS icon indicating copy to clipboard operation
excelFormulaUtilitiesJS copied to clipboard

Troublesome formula

Open glawrence opened this issue 8 years ago • 2 comments

I put in the following formula:

=IF(IF(ISERROR(SEARCH("bh", A6)), -1, SEARCH("bh", A6)) >=0, "Birmingham", IF(IF(ISERROR(SEARCH("sh", A6)), -1, SEARCH("sh", A6)) >=0, "Sheffield", IF(IF(ISERROR(SEARCH("lon", A6)), -1, SEARCH("lon", A6)) >=0, "London", "Unknown")))

However the -1 values do not come beautify very well and seems to cause a problem

I know we could debate formatting for ever but with the above I think the following looks better than the actual output:

=IF(
	IF(
		ISERROR(
			SEARCH("bh", A6)
		),
		-1,
		SEARCH("bh", A6)
	) >=0,
	"Birmingham",
	IF(
		IF(
			ISERROR(
				SEARCH("sh", A6)
			),
			-1,
			SEARCH("sh", A6)
		) >=0,
		"Sheffield",
		IF(
			IF(
				ISERROR(
					SEARCH("lon", A6)
				),
				-1,
				SEARCH("lon", A6)
			) >=0,
			"London",
			"Unknown"
		)
	)
)

glawrence avatar Dec 16 '17 13:12 glawrence

I see what you are saying, the -1 doesn't align consistently. I've flagged this as a feature and I'll dig in when I get though some of the other bugs. Thanks for the feedback!

joshbtn avatar Mar 29 '18 20:03 joshbtn

This is actually the same issue seen in issue #59

joshbtn avatar Mar 29 '18 21:03 joshbtn