Sorting a list based on ratios

AllanSull

Board Regular
Joined
Oct 21, 2013
Messages
105
I have a list of 46 unique items. I have a list of rules that specifies that some items need to be spaced a certain distance apart.

e.g.

46 Items

There are 14 of Item Type A
Item Type A's need to be spaced apart by (46/14)= 3.3 Items

Is there a way I can sort the list by these rules?

e.g.

Item Type A
Other item
Other Item
Other Item
Item Type A
Other Item
Other Item
Other Item
Item Type A
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Not sure what structure for your source data.

1. Type "Item Type A" in A1 and B1

option 1
A.select B1 to B4 (B2:B4 is blank),
B. drag it down to row184 (46x4)
option 2
A.Type following in C1
=INDEX(A:A,MOD(ROW(A4),4)+1,)

B. copy to row184




I have a list of 46 unique items. I have a list of rules that specifies that some items need to be spaced a certain distance apart.

e.g.

46 Items

There are 14 of Item Type A
Item Type A's need to be spaced apart by (46/14)= 3.3 Items

Is there a way I can sort the list by these rules?

e.g.

Item Type A
Other item
Other Item
Other Item
Item Type A
Other Item
Other Item
Other Item
Item Type A
 
Upvote 0
Not sure what structure for your source data.

1. Type "Item Type A" in A1 and B1

option 1
A.select B1 to B4 (B2:B4 is blank),
B. drag it down to row184 (46x4)
option 2
A.Type following in C1
=INDEX(A:A,MOD(ROW(A4),4)+1,)

B. copy to row184

My source data looks like this;

Item A
Item B
Item B
Item A
Item C
Item D
Item A
Item A

ect ect.

Each letter has its own rule depending on the the size of the sample and the frequency of the letter. In the above example Item A needs to be spaced 2 items apart (8/4). Item B 4 apart, Item C 8 apart and Item D 8 apart.

So the list should look like this;

Item A
Item C
Item A
Item B
Item A
Item D
Item A
Item B
 
Upvote 0
Hi,

I understand the rules re spacing, though in your Post #3, why does "Item C" come second in the list after "Item A" in your desired results? Why is it not "Item B"?

Also, what if the logic which generates each Item's spacing is not an integer value? Round up? Round down? Round to nearest integer?

Regards
 
Upvote 0
Hi,

I understand the rules re spacing, though in your Post #3, why does "Item C" come second in the list after "Item A" in your desired results? Why is it not "Item B"?

Also, what if the logic which generates each Item's spacing is not an integer value? Round up? Round down? Round to nearest integer?

Regards

It could be either Item B or Item C in that example as the rules are valid for both. If they are non integer values they would have to be rounded up as it cannot be for example 1.9 items apart, it would have to be 2.
 
Upvote 0
"It could be either Item B or Item C in that example as the rules are valid for both."

Sorry - not sure I understand. The "rule" appears to be valid for Item D as well, so are you saying that this could equally be in second position in the results list? So there's nothing at all to dictate the order of returns?

Regards
 
Upvote 0
Item D could indeed go there. The only rule is that the individual items need to be spaced apart according to their frequency relative to the total items.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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