Reputation: 23
I have a Google spreadsheet that shows date, customer names, products they bought and quantity. When a customer buys more than one product there are multiple rows with the same customer name, one for each product.
I'm trying to group all these rows with the same name using the same background color, and when a new group of rows containing another customer name is added, that group of rows has another color.
It is meant to simply alternate between two colors to facilitate visual grouping of the data.
I have achieved an almost useful result using the following formula as a Conditional Formatting:
=iseven(match($B2,unique($B$2:$B),0))
However, the "unique" function messes up the results once a repeat customer buys again because the name in the column is no longer unique. The group of rows with a repeat name will mimic the background color of the previous time this name was entered and mess up the alternating color pattern.
Is there any other function that would work instead?
I am looking for something easy preferably to be used as a conditional formatting.
Here is a link to the sheet: https://docs.google.com/spreadsheets/d/1HWVshPJiily77XR37RNcJLothyJkEWynkuTScpV97TY/edit?usp=sharing
Upvotes: 2
Views: 3182
Reputation: 1
try like:
=($B1<>"")*(ISEVEN(COUNTA(UNIQUE($B$1:$B1)))=TRUE)
or suggested:
=iseven(sumproduct(--($B$1:$B1<>$B$2:$B2)))
Upvotes: 3
Reputation: 34210
I think you want to count the number of times the name has changed and see if that is odd or even which can be done like this:
=iseven(sumproduct(--(B$1:B1<>B$2:B2)))
Upvotes: 1