Count IF with Unique in sheets

67 Views Asked by At

I'm having trouble completing formulas that combine COUNT IF with UNIQUE in Sheets.

This is my current formula, which works fine.

=COUNTIFS($AD:$AD,"Tour Operator",$AA:$AA,"DG",$AL:$AL,"Booked",$AM:$AM,I2)

I now need to add to it to only count if the entry in $AC:$AC is unique. How can this be done?

Further to this, how can it be adapted to ONLY count if two columns are unique, so the same formula as above but both $AC:$AC and $AM:$AM must be unique together to count as 1. To explain, the example below should count 3 unique entries.

AC AM test1 unique1 test1 unique1 test1 unique2 test2 unique3 test2 unique3

Thanks for any help, hope I've been clear enough in explaining.

1

There are 1 best solutions below

0
Diego On

=UNIQUE() can take in an array, so take advantage of that, but this will also return the blank rows (if any). Then use ROWS() to count the results. Since you're looking at two rows that aren't adjacent to each other, you'll need to combine them using curly braces. Since UNIQUE() may have returned an empty row, you can simply subtract by 1.

=ROWS(UNIQUE({$AC:$AC,$AM:$AM}))-1

Since it's not guaranteed that AC or AM will have blank rows, you could also filter out those blank rows:

=ROWS(UNIQUE({FILTER($AC:$AC, NOT(ISBLANK($AC:$AC))),FILTER($AM:$AM, NOT(ISBLANK($AM:$AM)))}))