TheKing
TheKing

Reputation: 3

How to prevent arrayformula from filling in empty rows (Google Sheets/Excel)

A B C
1 Apples Bananas Fruit
2 26 28 Banana
3 36 34 Apple
4 33 39 Banana
5 Banana
6 Banana

(Google Sheets) So over here I'm using arrayformula, on C1, to evaluate which type of fruit is larger in quantity.

The formula in C1: =arrayformula( { "Fruit"; if(A2:A>B2:B, "Apple", "Banana") } )

However, the rows starting from row 5 is filled up even though there isn't any input in the Apples and Bananas columns. Is there any way I could rewrite the formula in C1 such that these rows appear as blank? Also, due to the nature of the task, the =arrayformula function can't be removed. Appreciate the help, thanks!

Upvotes: 0

Views: 2387

Answers (1)

player0
player0

Reputation: 1

add another IF like:

=ARRAYFORMULA({"Fruit"; IF(A2:A="",, IF(A2:A>B2:B, "Apple", "Banana"))})

Upvotes: 1

Related Questions