Substituting Filter function in Excel 2016

Pbobas

New Member
Joined
Jun 21, 2024
Messages
4
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
Hi, I'm trying to replace a FILTER function on this Excel file which run on Excel 365 to an older version of Excel 2016. The goal is to list down products to be sourced to potential customers, either based on quantity (sorted either highest to lowest or vice versa) or by distance (nearest to furthest or vice versa). Tried to browse through several threads with no luck and given my limited Excel competency, I'm hoping anyone can be of assistance to shed some light on this. Any ideas are greatly appreciated.

DATA_BARU_TKI.xlsx
ABCDEFGHIJKL
21234BaseDistance
3ProductQtyCustomerDistanceColumn No.4
4CR3Y989574PT A10SortDescend-1
5CR3Y989637PT BRM15
6CR3Y989578PT C6ProductCustomer 1Customer 2Customer 3Customer 4Customer 5
7CR3Y9895710PT D4CR3Y98957PT APT ASDQWEPT BPT CPT D
8CR3Y989586PT X10CR3Y98963PT MIBPT BRM
9CR3Y9895812PT Y2CR3Y98958PT XPT YPT Z
10CR3Y989587PT Z1CR3Y98960PT ABCPT DEFPT GHIPT RSTPT TUV
11CR3Y9896020PT ABC50CR3Y98962PT ASDQWE
12CR3Y9896015PT DEF40 
13CR3Y9896013PT GHI30 
14CR3Y9896012PT RST20
15CR3Y9896010PT TUV10
16CR3Y98962100PT ASDQWE50
17CR3Y989576PT B8
18CR3Y989638PT MIB20
19CR3Y9895720PT ASDQWE10
Test
Cell Formulas
RangeFormula
B2:D2B2=A2+1
H3H3=IF(H2="Distance",$D$2,$B$2)
I4I4=IF(H4="Ascend",1,-1)
G7:G11G7=UNIQUE(FILTER(A4:A96,A4:A96<>""))
H7:L7,H12:CG13,H11,H10:L10,H9:J9,H8:I8H7=IF(IFNA(TRANSPOSE(INDEX(SORT(SORTBY(FILTER($A$4:$D$97,$A$4:$A$97=$G7), INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$G7),0,3),1, INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$G7),0,2),1),$H$3,$I$4),0,3)),"Check data")=0,"",IFNA(TRANSPOSE(INDEX(SORT(SORTBY(FILTER($A$4:$D$97,$A$4:$A$97=$G7), INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$G7),0,3),1, INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$G7),0,2),1),$H$3,$I$4),0,3)),"Check data"))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
H2List=Reference!$A$4:$A$5
H4List=Reference!$B$4:$B$5
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:
Instead of the formula in F4 ( you can drag this formula down as needed) to get the unique products, I'd just use the REMOVE DUPLICATES option under the data ribbon.
You can just drag the formula in G4 down and across as needed.
This is an array formula and you may need to enter it with CTRL-SHIFT-ENTER. I don't think you will have to though, since I used the AGGREGATE function.

Book2
ABCDEFGHIJK
1
21234
3ProductQtyCustomerDistanceProductCustomer 1Customer 2Customer 3Customer 4Customer 5
4CR3Y989574PT A10CR3Y98957PT APT ASDQWEPT BPT CPT D
5CR3Y989637PT BRM15CR3Y98963PT MIBPT BRM   
6CR3Y989578PT C6CR3Y98958PT XPT YPT Z  
7CR3Y9895710PT D4CR3Y98960PT ABCPT DEFPT GHIPT RSTPT TUV
8CR3Y989586PT X10CR3Y98962PT ASDQWE    
9CR3Y9895812PT Y2
10CR3Y989587PT Z1
11CR3Y9896020PT ABC50
12CR3Y9896015PT DEF40
13CR3Y9896013PT GHI30
14CR3Y9896012PT RST20
15CR3Y9896010PT TUV10
16CR3Y98962100PT ASDQWE50
17CR3Y989576PT B8
18CR3Y989638PT MIB20
19CR3Y9895720PT ASDQWE10
Sheet1
Cell Formulas
RangeFormula
B2:D2B2=A2+1
F4:F8F4=IFERROR(INDEX($A$4:$A$19,SMALL(IF(FREQUENCY(MATCH($A$4:$A$19,$A$4:$A$19,0),ROW($A$4:$A$19)-ROW($A$4)+1),ROW($A$4:$A$19)-ROW($A$4)+1),ROWS($F$4:F4))),"")
G4:K8G4=IFERROR(INDEX($C$4:$C$19,AGGREGATE(15,6,(ROW($C$4:$C$19)-ROW($C$4)+1)/($A$4:$A$19&"\"&$D$4:$D$19=$F4&"\"&AGGREGATE(14,6,IF($A$4:$A$19=$F4,$D$4:$D$19),COLUMNS($G$31:G31))),COUNTIF($G25:G25,G25))),"")
 
Upvote 1
Awesome, thanks for the idea. It worked wonders on the Product column, however when I tried to reproduce the solution to sort the customers, it returned blank cells instead as per below screenshot. Curious about the COLUMNS and COUNTIF function though, can you elaborate what does those 2 functions do here? Since they all seem to refer to blank cells.
DATA_BARU_TKI_testbaru.xlsx
ABCDEFGHIJK
1
21234BaseQuantity
3ProductQtyCustomerDistanceColumn No.2
4CR3Y989574PT A10SortAscend1
5CR3Y989637PT BRM15
6CR3Y989578PT C6ProductCustomer 1Customer 2Customer 3Customer 4Customer 5
7CR3Y9895710PT D4CR3Y98957     
8CR3Y989586PT X10CR3Y98963     
9CR3Y9895812PT Y2CR3Y98958     
10CR3Y989587PT Z1CR3Y98960     
11CR3Y9896020PT ABC50CR3Y98962     
12CR3Y9896015PT DEF40  
13CR3Y9896013PT GHI30 
14CR3Y9896012PT RST20
15CR3Y9896010PT TUV10
16CR3Y98962100PT ASDQWE50
17CR3Y989576PT B8
18CR3Y989638PT MIB20
19CR3Y9895720PT ASDQWE8
Test 2021 keatas
Cell Formulas
RangeFormula
B2:D2B2=A2+1
G3G3=IF(G2="Distance",$D$2,$B$2)
H4H4=IF(G4="Ascend",1,-1)
G7:K11H7=IFERROR(INDEX($C$4:$C$19,AGGREGATE(15,6,(ROW($C$4:$C$19)-ROW($C$4)+1)/($A$4:$A$19&"\"&$D$4:$D$19=$F7&"\"&AGGREGATE(14,6,IF($A$4:$A$19=$F7,$D$4:$D$19),COLUMNS($E$31:F31))),COUNTIF($E25:F25,F25))),"")
F7:F12F7=IFERROR(INDEX($A$4:$A$19,SMALL(IF(FREQUENCY(MATCH($A$4:$A$19,$A$4:$A$19,0),ROW($A$4:$A$19)-ROW($A$4)+1),ROW($A$4:$A$19)-ROW($A$4)+1),ROWS($F$7:F7))),"")
G12:CF13G12=IF(IFNA(TRANSPOSE(INDEX(SORT(SORTBY(FILTER($A$4:$D$97,$A$4:$A$97=$F12), INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$F12),0,3),1, INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$F12),0,2),1),$G$3,$H$4),0,3)),"Check data")=0,"",IFNA(TRANSPOSE(INDEX(SORT(SORTBY(FILTER($A$4:$D$97,$A$4:$A$97=$F12), INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$F12),0,3),1, INDEX(FILTER($A$4:$D$97,$A$4:$A$97=$F12),0,2),1),$G$3,$H$4),0,3)),"Check data"))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=Reference!$A$4:$A$5
G4List=Reference!$B$4:$B$5
 
Upvote 0
The formula I gave above isn't going to work.
The COUNTIF and COLUMNS functions are used as number increments for the LARGE function.
In the case of distance you have two customers for product CR3Y98957 that are at a distance of10. So in cell G4 the COUNTIF returns 1 for the first match and in cell H4 the COUNTIF returns a 2 for the second match in the table.

I had to add a helper matrix to get the formulas to work.

Book1
ABCDEFGHIJK
1
21234Distance
3ProductQtyCustomerDistanceProductCustomer 1Customer 2Customer 3Customer 4Customer 5
4CR3Y989574PT A10CR3Y98957PT ASDQWEPT APT BPT CPT D
5CR3Y989637PT BRM15CR3Y98963PT MIBPT BRM   
6CR3Y989578PT C6CR3Y98958PT XPT YPT Z  
7CR3Y9895710PT D4CR3Y98960PT ABCPT DEFPT GHIPT RSTPT TUV
8CR3Y989586PT X10CR3Y98962PT ASDQWE    
9CR3Y9895812PT Y2
10CR3Y989587PT Z1Helper Matrix for Distance
11CR3Y9896020PT ABC50CR3Y989571010864
12CR3Y9896015PT DEF40CR3Y989632015   
13CR3Y9896013PT GHI30CR3Y989581021  
14CR3Y9896012PT RST20CR3Y989605040302010
15CR3Y9896010PT TUV10CR3Y9896250    
16CR3Y98962100PT ASDQWE50
17CR3Y989576PT B8
18CR3Y989638PT MIB20QtyCustomer 1Customer 2Customer 3Customer 4Customer 5
19CR3Y9895720PT ASDQWE10CR3Y98957PT ASDQWEPT DPT CPT BPT A
20CR3Y98963PT MIBPT BRM   
21CR3Y98958PT YPT ZPT X  
22CR3Y98960PT ABCPT DEFPT GHIPT RSTPT TUV
23CR3Y98962PT ASDQWE    
24
25Helper Matrix for Qty
26CR3Y989572010864
27CR3Y9896387   
28CR3Y989581276  
29CR3Y989602015131210
30CR3Y98962100    
Sheet1
Cell Formulas
RangeFormula
B2:D2B2=A2+1
F4:F8F4=IFERROR(INDEX($A$4:$A$19,SMALL(IF(FREQUENCY(MATCH($A$4:$A$19,$A$4:$A$19,0),ROW($A$4:$A$19)-ROW($A$4)+1),ROW($A$4:$A$19)-ROW($A$4)+1),ROWS($F$4:F4))),"")
G4:K8G4=IF(G11="","",(INDEX($C$4:$C$19,AGGREGATE(14,6,(ROW($C$4:$C$19)-ROW($C$4)+1)/($A$4:$A$19&"\"&$D$4:$D$19=$F4&"\"&G11),COUNTIF($G11:G11,G11)))))
G11:K15G11=IFERROR(AGGREGATE(14,6,IF($A$4:$A$19=$F4,$D$4:$D$19),COLUMNS($G$1:G1)),"")
G19:K23G19=IF(G26="","",(INDEX($C$4:$C$19,AGGREGATE(14,6,(ROW($C$4:$C$19)-ROW($C$4)+1)/($A$4:$A$19&"\"&$B$4:$B$19=$F4&"\"&G26),COUNTIF($G26:G26,G26)))))
G26:K30G26=IFERROR(AGGREGATE(14,6,IF($A$4:$A$19=$F4,$B$4:$B$19),COLUMNS($G$1:G1)),"")
 
Upvote 1
Solution
Awesome, that last piece totally clears things up. Thank you again for the help (y)
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

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