Return Unique List Based on Criteria

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,142
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
Hi

Hoping someone can help me tidy this up, I need to return the items in column AI where column AJ has a value greater than or equal to 25 and is also the first instance of that value (I've highlighted these in yellow). I have managed to cobble together a working solution which is included here. I'm hoping that someone may be able to simplify it. The values in column AI are fairly immaterial, the important piece is that column AJ is above 25 and the first instance in the column of that value.

Book2
AHAIAJAKAL
1
2Apple0Chocolate
3Pear0Banana
4Chocolate30Cherry
5Banana25Lobster
6Cherry27 
7Prawns27 
8Lobster29 
9
Sheet1
Cell Formulas
RangeFormula
AL2:AL8AL2=IFERROR(INDEX($AI$2:$AI$8,SMALL(IF(FREQUENCY(IF($AJ$2:$AJ$8>=25,MATCH($AJ$2:$AJ$8,$AJ$2:$AJ$8,0)),ROW($AJ$2:$AJ$8)-ROW($AJ$2)+1)>0,ROW($AJ$2:$AJ$8)-ROW($AJ$2)+1),ROWS($A$1:$A1))), "")


If possible I would like this to work in Office 2016, but I do plan to roll it out at some point to M365 so if there is an alternative then I'd really like to see it.

TIA, best regards, Dave
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
The following seems to work in 365, but I haven't come up with something that could be used in 2016 as yet.

Book1
AIAJAKAL
2Apple0Banana
3Pear0Cherry
4Chocolate20Lobster
5Banana25Tomato
6Cherry27
7Prawns27
8Lobster29
9Tomato50
10Orange50
Sheet1
Cell Formulas
RangeFormula
AL2:AL5AL2=INDEX(AI2:AI10,MATCH(FILTER(UNIQUE(AJ2:AJ10),25<=UNIQUE(AJ2:AJ10)),AJ2:AJ10,0))
Dynamic array formulas.
 
Upvote 0
Another - not so simple, but it works in Excel 2016

Pasta3
AIAJAKAL
1
2Apple0Chocolate
3Pear0Banana
4Chocolate30Cherry
5Banana25Lobster
6Cherry27 
7Prawns27 
8Lobster29 
Plan7
Cell Formulas
RangeFormula
AL2:AL8AL2=IFERROR(INDEX(AI$2:AI$8,AGGREGATE(15,6,(ROW(AI$2:AI$8)-ROW(AI$2)+1)/((AJ$2:AJ$8>=25)*(MATCH(AJ$2:AJ$8,$AJ$2:$AJ$8,0)=ROW(AJ$2:AJ$8)-ROW(AJ$2)+1)),ROWS(AL$2:AL2))),"")


M.
 
Upvote 0
Solution
A Power Query Solution that should work in both versions

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type", {"Column2"}),
    #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "Custom", each if[Column2]>=25 then [Column1] else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Custom"})
in
    #"Removed Other Columns"
 
Upvote 0
Another 365 formula option if you have the LET function.

21 07 29.xlsm
AIAJAKAL
1
2Apple0Chocolate
3Pear0Banana
4Chocolate30Cherry
5Banana25Lobster
6Cherry27
7Prawns27
8Lobster29
9
List
Cell Formulas
RangeFormula
AL2:AL5AL2=LET(r,AJ2:AJ8,FILTER(AI2:AI8,(r>=25)*(MATCH(r,r,0)=SEQUENCE(ROWS(r)))))
Dynamic array formulas.
 
Upvote 0
Thanks everyone for your fine suggestions. Apologies for the delayed response I had a bit of a busy day.

Kind regards, Dave
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

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