SORT FILTER Two Columns when either has a criteria

GeeWhiz7

Board Regular
Joined
Nov 22, 2021
Messages
214
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,

Based on something Fluff helped me with in this post, I have an original list of items that get put into an array of their total non-recursive combinations.

Fluff helped me to get rid of cases that had zeros in the list as my source data (not fruit) from users occasionally had zeros. Now what I notice in use is there are other bad data that I want to filter out.

See mini-sheet for idea. I have tried SORT(FILTER()), IF(AND()), but can't quite get what I want.

Goal:
Filter either as a new array or in-place, the combinations (cols D&E), to only include the good values of fruit and omit "junk" or "tax credit"

Constraints:
  • Needs to be non-vba solution.
  • Needs to keep the viable combinations with each other (ie a row with good/good data needs to be sorted to stay together)
  • Needs to be able to work on any number of rows, but always just two columns.
Example:
Book3
ABCDEFGH
1ListCombinationsDesired Result
2AppleAppleOrangeAppleOrange
3OrangeAppleMelonAppleMelon
4MelonAppletax creditOrangeMelon
5tax creditApplejunk
6junkApplejunk
7junkOrangeMelon
8Orangetax credit
9Orangejunk
10Orangejunk
11Melontax credit
12Melonjunk
13Melonjunk
14tax creditjunk
15tax creditjunk
16junkjunk
Sheet1


Thank you for your help!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
Excel Formula:
=LET(Rng,FILTER(B2:B50,(B2:B50<>0)*(B2:B50<>"tax credit")*(B2:B50<>"junk")),r,ROWS(Rng),b,BASE(SEQUENCE(r^2,,0),r,2),f,FILTER(b,LEFT(b)<>RIGHT(b)),m,MID(f,{1,2},1),mm,IF(CODE(m)>64,CODE(m)-54,m+1),by,BYROW(m,LAMBDA(br,CONCAT(SORT(br,,,1)))),rr,ROWS(by),FILTER(INDEX(Rng,mm),MMULT((SEQUENCE(rr)>=SEQUENCE(,rr))*(by=TRANSPOSE(by)),SEQUENCE(rr,,,0))=1))
 
Upvote 0
How about
Excel Formula:
=LET(Rng,FILTER(B2:B50,(B2:B50<>0)*(B2:B50<>"tax credit")*(B2:B50<>"junk")),r,ROWS(Rng),b,BASE(SEQUENCE(r^2,,0),r,2),f,FILTER(b,LEFT(b)<>RIGHT(b)),m,MID(f,{1,2},1),mm,IF(CODE(m)>64,CODE(m)-54,m+1),by,BYROW(m,LAMBDA(br,CONCAT(SORT(br,,,1)))),rr,ROWS(by),FILTER(INDEX(Rng,mm),MMULT((SEQUENCE(rr)>=SEQUENCE(,rr))*(by=TRANSPOSE(by)),SEQUENCE(rr,,,0))=1))
Hi Fluff, this works and I had thought of using your original code, but I am having issues with the number of combinations. Originally I thought a list of 35-55 might work, but with an input list of 50 there are close to 1200 combination rows. So, I had a little bit of a workaround using your code from before and hand editing out/repasting values.

Do you think there is a way to do this without the limitation no entry #s?
 
Upvote 0
The only way I know to do permutations like that is with the Base function, which is limited to 36
 
Upvote 0
The only way I know to do permutations like that is with the Base function, which is limited to 36
Okay, thanks for looking. If I can figure out how to do it from the original function code in the original post, I will post it here.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

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