# Excel count unique values from column, based on criteria from another

I'm using
=SUM(N(FREQUENCY(C2:C25,C2:C25)>0))
to get a total of the unique values in the range, but I also want to narrow it down a bit more.

I only want the total of unique values based on criteria from another column.

For example:
=COUNTIF(V2:V25,"sometext")

How can I combine these formulas?

Thanks!
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
=SUM(N(FREQUENCY(C2:C25,C2:C25*(V2:V25="sometext"))>0))
Commented:
That didn't work, due to blanks in V2:V25 interfering and adding 1 to the total

This works

=SUM(N(FREQUENCY(C2:C25*(V2:V25="sometext"),C2:C25*(V2:V25="sometext"))>0))-(COUNTIF(V2:V25,"")<>ROWS(V2:V25))

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
hehe, can we make this more complicated -  Is is possible to do this evaluation twice and combine again?

=SUM(N(FREQUENCY(C2:C25*(V2:V25="sometext"),C2:C25*(V2:V25="sometext"))>0))-(COUNTIF(V2:V25,"")<>ROWS(V2:V25))

=SUM(N(FREQUENCY(C2:C25*(U2:U25="othertext"),C2:C25*(U2:U25="othertext"))>0))-(COUNTIF(U2:U25,"")<>ROWS(U2:U25))

I don't want to add them, as some of the unique values will overlap
Commented:
Twice? You mean V has to be sometext and U has to be othertext?
Author Commented:
On second thought, I'll post this as a new question and update with a link to the new post
Author Commented:
oh lol you're online! we posted at the same time.  Want me to do a new post, or keep this going?

Yeah, it would based on two sets of data.  I 'd like a unique count from C where V is sometext, and U is othertext
Commented:
Let's see which is faster.. :)
Commented:
Try this

=SUM(N(FREQUENCY(C2:C25*(V2:V25="sometext")*(U2:U25="othertext"),C2:C25*(V2:V25="sometext")*(U2:U25="othertext"))>0))-(OR(COUNTIF(V2:V25,"*")<>ROWS(V2:V25),COUNTIF(U2:U25,"*")<>ROWS(V2:V25)))
Author Commented:
Commented:
Hi TelMaco,

I double checked and there were some cases where my formula returns the incorrect result.

the correct formula should be

=SUMPRODUCT((U2:U25="sometext")*(V2:V25="othertext")*(C2:C25<>"")/COUNTIFS(U2:U25,U2:U25&"",V2:V25,V2:V25&"",C2:C25,C2:C25&""))

As given by Barry in http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26926181.html#a35287823

Regards
Author Commented:
Just coming back to post an update...I noticed some issues too.  Thanks for following up, I'll check out the new formula.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.