SOLVED

Calculate the count without duplicates

Brass Contributor

I am looking for a formula to calculate the count without duplicates for unique combinations of "Country," "Code," and "Serial" 

 

The result for country Mexico and Code 0014 should be 4 because it has 4 different Serial and for Canada's Code 0206 should be 3 (Three different Serial).

 

Can you please help with a formula to have this calculation?

 

Customer Country DescriptionCodeSerialResultad
Mexico0014X4
Mexico0014Y4
Mexico0014Y4
Mexico0014Z4
Mexico0014Z4
Mexico0014W4
Canada0206A3
Canada0206B3
Canada0206C3

 

Thanks.

5 Replies
The desired formula should go for each row as shown in the table above on column "Resultad"

@diego9010 

=BYROW(A2:C10,LAMBDA(y,COUNTA(UNIQUE(TAKE(FILTER($A$2:$C$10,($A$2:$A$10=TAKE(y,,1))*($B$2:$B$10=CHOOSECOLS(y,2))),,-1)))))

 

With Office 365 or Excel 2021 or Excel for the web you can apply this formula.

 

byrow lambda.png

@diego9010 

An alternative could be Power Query. In the attached file you can add data to the blue dynamic table. Then you can click in any cell of the green table and right-click with the mouse and select refresh to update the green result table.

 

count without duplicates.png

Hi, thanks a lot.

Wow, that formula is very complex jeje. Would it be possible to do something with sumproduct and countifs for instance?

Thanks!
best response confirmed by diego9010 (Brass Contributor)
Solution

@diego9010 

=MAP(A2:A10,B2:B10,LAMBDA(customer,code,COUNTA(UNIQUE(FILTER(C2:C10,(A2:A10=customer)*(B2:B10=code))))))

 

You are welcome. This formula is a little bit shorter.

map lambda.png

 

Unfortunately i don't know how we can do this with SUMPRODUCT and COUNTIFS and without LAMBDA, UNIQUE functions.

 

 

1 best response

Accepted Solutions
best response confirmed by diego9010 (Brass Contributor)
Solution

@diego9010 

=MAP(A2:A10,B2:B10,LAMBDA(customer,code,COUNTA(UNIQUE(FILTER(C2:C10,(A2:A10=customer)*(B2:B10=code))))))

 

You are welcome. This formula is a little bit shorter.

map lambda.png

 

Unfortunately i don't know how we can do this with SUMPRODUCT and COUNTIFS and without LAMBDA, UNIQUE functions.

 

 

View solution in original post