TEXTJOIN return UNIQUE values with INDEXMATCH multiple criteria

WhimsicalRaptor87

New Member
Joined
Jul 24, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I'm using this formula to search multiple ranges that contain dates and if they fall between a set range (=List!C1 and =List!D1 in my example sheet), then return the value from a different column, then join the resulting values:

=TEXTJOIN(", ",TRUE,
IFERROR(INDEX(Input!$N$2:$N$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$M$2:$M$17>=List!$C$1)*(Input!$L$2:$L$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$K$2:$K$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$J$2:$J$17>=List!$C$1)*(Input!$I$2:$I$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$H$2:$H$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$G$2:$G$17>=List!$C$1)*(Input!$F$2:$F$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$E$2:$E$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$D$2:$D$17>=List!$C$1)*(Input!$C$2:$C$17<=List!$D$1),0)),""))

However, I'd like it to return distinct values. So for Luna Starfire, E6 should only say 'Squirtle, Snorlax'. I've attempted adding in UNIQUE many times but it either still returns multiple values or returns an error.

Here is the sheet where I'm attempting to run the formula above in cell E4:E12:
ExampleExcel.xlsx
ABCDE
1Time periodFY20231/07/202230/06/2023
2
3NameStart DateEnd DateOriginal PokemonCurrent Pokemon
4Jade Skywalker30/01/202326/05/2023Pikachu, SnorlaxSnorlax, Pikachu, Snorlax
5Jade Skywalker30/01/202031/12/2023PikachuPikachu, Pikachu
6Luna Starfire30/08/202028/08/2023Squirtle, SnorlaxSquirtle, Squirtle, Snorlax
7Maverick Sapphire17/05/202315/11/2023Snorlax, SquirtleSquirtle, Snorlax, Squirtle
8Nova Midnight28/02/202327/02/2024EeveeEevee
9Orion Thunder4/05/20225/08/2023SquirtleSquirtle
10Phoenix Frost9/07/20227/01/2023Jigglypuff, Eevee, MeowthMeowth, Jigglypuff, Eevee, Meowth
11Willow Dreamer30/03/20234/06/2023Mewtwo, EeveeMewtwo, Eevee
12Zephyr Wanderer16/11/202217/05/2023Mewtwo, EeveeMewtwo, Eevee, Meowth, Mewtwo, Eevee
List
Cell Formulas
RangeFormula
A4:C12A4=SORT(UNIQUE(FILTER(CHOOSE({1,2,3},Input!A2:A17&" "&Input!B2:B17,Input!C2:C17,Input!D2:D17),(Input!D2:D17>=List!C1)*(Input!C2:C17<=List!D1))))
D4:D12D4=IFERROR(INDEX(Input!$E$2:$E$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*(List!$B4=Input!$C$2:$C$17)*(List!$C4=Input!$D$2:$D$17),0)),"")
E4:E12E4=TEXTJOIN(", ",TRUE, IFERROR(INDEX(Input!$N$2:$N$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$M$2:$M$17>=List!$C$1)*(Input!$L$2:$L$17<=List!$D$1),0)),""), IFERROR(INDEX(Input!$K$2:$K$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$J$2:$J$17>=List!$C$1)*(Input!$I$2:$I$17<=List!$D$1),0)),""), IFERROR(INDEX(Input!$H$2:$H$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$G$2:$G$17>=List!$C$1)*(Input!$F$2:$F$17<=List!$D$1),0)),""), IFERROR(INDEX(Input!$E$2:$E$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$D$2:$D$17>=List!$C$1)*(Input!$C$2:$C$17<=List!$D$1),0)),""))
Dynamic array formulas.


And here is my source data:
ExampleExcel.xlsx
EFGHIJKLMN
1All PokemonExtension 1 start dateExtension 1 end datePokemonExtension 2 start dateExtension 2 end datePokemonExtension 3 start dateExtension 3 end datePokemon
2Pikachu, Snorlax1/01/202331/01/2023Snorlax
3Snorlax, Squirtle1/04/202215/11/2023Squirtle
4Squirtle, Snorlax18/12/202017/12/2021Squirtle18/12/202118/05/2022Squirtle, Snorlax19/05/202228/08/2023Squirtle
5Squirtle
6Jigglypuff, Eevee, Meowth10/12/20227/01/2023Meowth
7Eevee
8Mewtwo, Eevee1/02/202331/03/2023Meowth1/04/202317/05/2023Mewtwo, Eevee
9Mewtwo, Eevee
10Snorlax
11Mewtwo
12Mewtwo, Eevee23/09/201913/10/2019Mewtwo, Eevee14/10/201912/11/2019Eevee
13Jigglypuff, Eevee1/05/202030/06/2020Jigglypuff
14Pikachu, Snorlax
15Pikachu17/08/202016/09/2020Pikachu
16Pikachu29/10/202229/10/2023Pikachu30/10/202329/11/2023Pikachu30/11/202331/12/2023Pikachu
17Squirtle
Input


Thank you!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
List!A4 references Input!A2:D17 which is unknown since you excluded it...

Haven't looked in detail, but with the way your source data is set up, I'm going to assume you need to split the text, by the comma delimiter before using unique.
 
Upvote 0
Solution
Thank you! I got it working using this:

=TEXTJOIN(", ",, UNIQUE(TEXTSPLIT(TEXTJOIN(", ",,
IFERROR(INDEX(Input!$N$2:$N$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$M$2:$M$17>=List!$C$1)*(Input!$L$2:$L$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$K$2:$K$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$J$2:$J$17>=List!$C$1)*(Input!$I$2:$I$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$H$2:$H$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$G$2:$G$17>=List!$C$1)*(Input!$F$2:$F$17<=List!$D$1),0)),""),
IFERROR(INDEX(Input!$E$2:$E$17,MATCH(1,($A4=Input!$A$2:$A$17&" "&Input!$B$2:$B$17)*($B4=Input!$C$2:$C$17)*(Input!$D$2:$D$17>=List!$C$1)*(Input!$C$2:$C$17<=List!$D$1),0)),"")),", "),TRUE),,,)
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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