Do the items in Bin Array (Frequency Function) have to be sorted?

caniever

New Member
Joined
May 5, 2018
Messages
7
I have browsed a lot of Excel websites, and the result is yes. But when I try it out myself, I think Excel somehow arranges the items of the bin array in ascending order when it executes the Frequency function, no matter how randomly you put them in the list.

Anyone cares to share their thoughts on this? : )
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

Can you give an example of a website which states that the values in the bins_array need to be sorted?

They do not, though you must realise that the returns you receive will be with respect to the order of values entered as the bins_array. For example:

=SUM(FREQUENCY({1,2,5,5,5,3,3,3,3,7},{5,1,3}))

will resolve to:

=SUM({3;1;5;1})

Regards
 
Upvote 0
Thanks for the reply. I don't know if it violates any rules here by posting other web links directly, but in brief, I just googled the question and the top few websites I was given all said yes.
 
Upvote 0
Nearly all websites assert that Excel "stores" 15 significant decimal digits of precision for numeric values. That does not make them right. In fact, they are wrong !

Apparently, that is also the case with regard to your question about the order of values in the bins array. (Suprise !)

For a more visible demonstration, enter 1, 3, 3, 5, 5, 5, 7, 7, 7, 7 into A1:A10.

Select B1:B5 and array-enter =FREQUENCY(A1:A10,{7,5,3,1})). Note that the correct counts are returned, namely 4,3,2,1, but in the order of the bins array values.

Select C1:C5 and array-enter =FREQUENCY(A1:A10,{1,3,5,7}). Note that, again, the correct counts are returned in the order of the bins array values.

Finally, normally-enter the formula =MATCH(A1,{7,5,3,1}) into D1. Copy D1 and paste into D2:D10. Note that either #N/A or the wrong index is returned except for 5, by coincidence.

That demonstrates that if FREQUENCY depended on ascending order and performed a binary search of the bins array, like MATCH, FREQUENCY would have returned errors or erroneous results.

So I agree with "XOR XL": these exercises, as well as your own, seem to demonstrate that FREQUENCY is not sensitive to the order of values in bins array, notwithstanding "conventional wisdom".

Nevertheless, the only way to prove the assertion is to find MSFT documentation that supports it. Otherwise, there might exist a counter-example that disproves the conclusion. (And unfortunately, MSFT is not dispositive, because it is sometimes incorrect.)

For that reason, I would not depend on undocumented behavior.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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