Sorting with a formularised column

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
433
Office Version
  1. 365
Platform
  1. Windows
I have a list of products Column C which has come from a different sheet (Pivot Top Sellers) based on a group name in Column B.
Using the code below it provides me a list of products that are specific to just that group.

Excel Formula:
=IFERROR(INDEX('Pivot Top Sellers'!C:C, SMALL(IF((Dashboard!$CE$10='Pivot Top Sellers'!B:B), MATCH(ROW('Pivot Top Sellers'!B:B), ROW('Pivot Top Sellers'!B:B)), ""),ROWS($A$1:A1))),"-")

Where this final data is in a separate worksheet (Dashboard) there are various other columns next to the products, which I would like to sort on.
Because the formula above brings the data in as a list in the order of the sheet where it gets the info from, when I sort it, it does not change the products order.
Is there any other ways to bring in the products so they can be sorted?

Any help would be appreciated.
 
Last edited by a moderator:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
On what basis do you want to bring the data in then? In other words, how does it relate to the adjacent columns?
 
Upvote 0
I have the Group as a user selection from a user drop down box, so the formula goes and looks for the user selection in a separate worksheet and with the code sent previously finds all the products that relate to that group and lists them in a column.
Once it has listed all the products the columns to the right of the products are sales and ranking columns which I want to sort the list of products on. To get all the sales data I use SUMIfs formulas using the product name to search from a another separate worksheet with all the sales on.

Hope that helps a little.
 
Upvote 0
Just on your post code XL2BB.
I tried to add in that option but it doesn't appear in the list of add on's
 
Upvote 0
=IFERROR(INDEX('Pivot Top Sellers'!C:C, SMALL(IF((Dashboard!$CE$10='Pivot Top Sellers'!B:B), MATCH(ROW('Pivot Top Sellers'!B:B), ROW('Pivot Top Sellers'!B:B)), ""),ROWS($A$1:A1))),"-")

Where this final data is in a separate worksheet (Dashboard)
If that means that the quoted formula is on the Dashboard sheet, then you don't need the Dashboard! reference for cells/ranges on that sheet. Further, doing so can cause exactly this type of problem with sorting. There is a simple example here to demonstrate the issue.

So, if the formula is on Dashboard then the first thing I would try is removing that Dashboard! from the formula
Excel Formula:
=IFERROR(INDEX('Pivot Top Sellers'!C:C, SMALL(IF(($CE$10='Pivot Top Sellers'!B:B), MATCH(ROW('Pivot Top Sellers'!B:B), ROW('Pivot Top Sellers'!B:B)), ""),ROWS($A$1:A1))),"-")
 
Upvote 0
A couple more suggestions
- That formula makes my test workbook very sluggish - because you are referencing whole columns. Surely you are not using a million+ rows? Try restricting the column row ranges if possible.

- Since you have Excel 365 you (should) have some new functions that can make this job much simpler. If you have the FILTER function then try this (check row range is sufficient for your data) in a single cell. The other results should automatically 'spill' down the column.

Excel Formula:
=FILTER('Pivot Top Sellers'!C1:C1000,'Pivot Top Sellers'!B1:B1000=$CE$10,"")
 
Upvote 0
The issue is that your formula is actually sorting the results it returns. If you can replace the ROWS($A$1:A1) part with hardcoded row numbers, then the sorting should work. Alternatively, depending where the sales and ranking data comes from, perhaps you should be using a pivot table and a slicer to select the Group.
 
Upvote 0
I tried the first example removing the word Sheet Name "Dashboard", but that didn't change anything with the sort the list still stayed the same order after the sort.
I then used the filter option and when I went to sort it says I cannot sort on an array.
Any other thoughts?
Thanks for all your help so far.
 
Upvote 0
Hi RoryA
I tried taking away the hard coding but it didn't work on the sort. Looked like it was going to but then it reverted back to the original list.
The data comes from a large list so I don't know where each product will be in the list hence it looks for the group then selects each line in the group.
I'm going to a meeting now, but if you have any other thoughts that would be great.
I could do the pivot but it would then mean doing a pivot every time a new group was selected.
Thank you so far for your help.
 
Upvote 0
You only need one pivot - you simply filter it for whichever group you need.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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