Textjoin With Multiple "And" Conditions/Criteria?

olimits7

Board Regular
Joined
Oct 29, 2004
Messages
229
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to use a TEXTJOIN with multiple "and" criteria/conditions, I almost got it to work with the following formula but it shows "FALSE" in the text output instead of just being blank. For example, "FALSE, M12345, M45678, M99584, etc.".

Excel Formula:
={TEXTJOIN(", ",TRUE,UNIQUE(IF('YTD Transactions'!$U:$U=$B17,IF(LEFT('YTD Transactions'!$R:$R,2)="43",'YTD Transactions'!$AG:$AG),"")))}

I'm trying to setup 2 different TEXTJOIN's; one where $R:$R equals "43" and the other where it equals "41", and also matches to whatever value is in $B17 under $U:$U.

I also tried this but gives me a #VALUE error.

Excel Formula:
={TEXTJOIN(", ",TRUE,UNIQUE(IF(('YTD Transactions'!$U:$U=$B17)*(LEFT('YTD Transactions'!$R:$R,2)="41"),'YTD Transactions'!$AG:$AG),""))}

Thank you!
 
Perhaps this one,
Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*((LEFT('YTD Transactions'!$R:$R,2)="43")+(LEFT('YTD Transactions'!$R:$R,2)="41")),"")))
There are a few ways to interpret what you asked for so I've gone with the most common one.

This gets me back to my original formula, I'm basically trying to show 2 separate output of values; for example:

IF $R:$R equals "43" and $U:$U equals $B17, then value [Textjoin Example Output: AAA, BBB, CCC]
OR
IF $R:$R equals "41" and $U:$U equals $B17, then value [Textjoin Example Output: 111, 222, 333]

With current formula, I'm getting this Textjoin Example Output: [AAA, BBB, CCC, 111, 222, 333], which is not what I need.

Ty
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
If you need 2 outputs then you need 2 formulas, 1 for 43 and another for 41 (as @Fluff pointed out in post 6).

I think that the penny has just dropped, were you using the array confirmation across 2 cells to get one output in each? If so then this might allow the formula to spill dynamically (not tested).
Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*(LEFT('YTD Transactions'!$R:$R,2)={"43";"41"}),"")))
 
Last edited:
Upvote 0
If you need 2 outputs then you need 2 formulas, 1 for 43 and another for 41 (as @Fluff pointed out in post 6).

I think that the penny has just dropped, were you using the array confirmation across 2 cells to get one output in each? If so then this might allow the formula to spill dynamically (not tested).
Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*(LEFT('YTD Transactions'!$R:$R,2)={"43";"41"}),"")))

I just tried this but gives #N/A error. But what you wrote in {"43";"41"} , would this return values that equal both of these in a single cell (e.g. $A$1)?

If data equals "43", $A$1 would show only AAA, BBB, CCC textjoin data
If data equals "41", $A$1 would show only 111, 222, 333 textjoin data

Ty.
 
Upvote 0
The below works properly if I add each formula to a separate cell but I need to have this show within 1 cell, either show output for "41" or output for "43", not both at the same time.

Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*((LEFT('YTD Transactions'!$R:$R,2)="43")),"")))

Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*((LEFT('YTD Transactions'!$R:$R,2)="41")),"")))

Ty.
 
Upvote 0
How are we to know which one should be shown at any given time?

Oh ok, I see what you mean; that's why I was trying to wrap this around around an IF statement, but maybe I need to have the data setup like the following and then I could use an IF statement wrapped around?

$B17= Customer # (e.g. AB123)
$C17= 41 or 43 (depending on data)

For example:
IF $B17=AB123 AND $C17 = 41, THEN "TEXTJOIN W/ 41 FORMULA", IF $B17=AB123 AND $C17 = 43, THEN "TEXTJOIN W/ 43 FORMULA" - Would something like this work?
 
Upvote 0
How about
Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*((LEFT('YTD Transactions'!$R:$R,2)=C17&"")),"")))
 
Upvote 0
Solution
How about
Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*((LEFT('YTD Transactions'!$R:$R,2)=C17&"")),"")))

Ok, what you wrote does work...Ty. I'm just trying to modify it slightly because in my current pivot table I'm not showing the "41", "43" values instead I have the following which translates to these values.

In $E17 it shows either "PROJECT" for "43" or "PARTNER" for "41"; so I tried updating your formula to the following below but now getting an #N/A error. $AB:$AB is where this text is saved in the source data.

Excel Formula:
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER('YTD Transactions'!$AG:$AG,('YTD Transactions'!$U:$U=$B17)*('YTD Transactions'!$AB:$AB=$E17)),""))

Ty.
 
Upvote 0
You should only get #N/A with that formula if col AG has that error on one of the rows that match the criteria.
 
Upvote 0

Forum statistics

Threads
1,215,741
Messages
6,126,594
Members
449,320
Latest member
Antonino90

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