Identify distinct values based upon multiple criteria

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
I am trying to use a formula to obtain a count of the number of distinct values in a list of data I have.

I can use the follow:

=sum(1/countif(ID_Range,ID_Range))

And it returns the correct number of distinct IDs in the range.

However, I need to expand my number of criteria to something such as:

=sum(1/countifs(Item_Range,$A2,Location_Range,$B2,ID_Range,ID_Range)

I am getting decimal points instead of whole numbers ..... throwing me off a bit.

Thanks for your help!

-Spydey
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Could you provide a small data sample, criteria and expected results?

M.

Actually, I think I got it. I had to approach it from a different angle. I was on the right path but just needed to tweak and adjust a few things.

My ending formula is:

=sum(if($A2=Item_Range,1/(countifs(Item_Range,$A2,Location_Range,$B2,ID_Range,ID_Range)),0))

confirmed with CSE.

Looks to be working correctly.

Thanks though Marcelo!

Cheers!

-Spydey
 
Upvote 0
Great you solved your problem!

I was thinking in a better (much faster) formula using the FREQUENCY function. You can find in this forum many threads that use this kind of formula to get a unique (distinct) count .

M.
 
Upvote 0
I will have to search around for that. I have noticed that it does take it a moment or more to provide the result. Most likely Frequency would be faster. Thanks for the tip!

-Spydey
 
Upvote 0
I will have to search around for that. I have noticed that it does take it a moment or more to provide the result. Most likely Frequency would be faster. Thanks for the tip!

-Spydey

With a small sample of data, and criteria, i can show you an example of such formulas.

M.
 
Upvote 0
Control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-(ID_Range=""),IF($A2=Item_Range,IF($B2=Location_Range,MATCH(ID_Range,ID_Range,0)))),ROW(ID_Range)-ROW(INDEX(ID_Range,1,1))+1),1))

would be faster thann:

=sum(if($A2=Item_Range,1/(countifs(Item_Range,$A2,Location_Range,$B2,ID_Range,ID_Range)),0))
 
Upvote 0
Control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-(ID_Range=""),IF($A2=Item_Range,IF($B2=Location_Range,MATCH(ID_Range,ID_Range,0)))),ROW(ID_Range)-ROW(INDEX(ID_Range,1,1))+1),1))

would be faster thann:

=sum(if($A2=Item_Range,1/(countifs(Item_Range,$A2,Location_Range,$B2,ID_Range,ID_Range)),0))

So I ended up using what you provided above, and changed a few things. It works wonderfully! Thank you so much for your assistance.

-Spydey
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top