Forum Discussion
Need to build a string based on conditions
- Jan 28, 2020
It could be
=TEXTJOIN(",",TRUE,IF(Booth_TBL[Company]=[@Company],Booth_TBL[Booth Label],""))if we speak about Booth Number(s) column
JBF_54 OK ... I uploaded a sample spreadsheet.
The general back story is that my group puts on a fishing show and rents booths to vendors. In an effort to get rid of some manual (error prone) data entry, I would like to find a way for a field in a Vendor record (1 record per vendor) to look into another table containing Booth records (1 record per booth) and build a list of Booth Numbers that the Vendor has rented.
- SergeiBaklanJan 28, 2020Diamond Contributor
It could be
=TEXTJOIN(",",TRUE,IF(Booth_TBL[Company]=[@Company],Booth_TBL[Booth Label],""))if we speak about Booth Number(s) column
- JBF_54Jan 28, 2020Brass Contributor
How elegant ... thanks very much.
To test multiple conditions I modified the formula (highlighted in red), and of course, I populated the Tables Needed column with some data. It returned nulls in all cases. Would you have expected this to work?
=TEXTJOIN(", ",TRUE,IF(AND(Booth_TBL[Tables Needed]>0,Booth_TBL[Company]=[@Company]),Booth_TBL[Booth Label],""))
- SergeiBaklanJan 28, 2020Diamond Contributor
Nope, that doesn't work since AND() returns only first element of the array with conditions. Instead use equivalent formula
=TEXTJOIN(", ",TRUE,IF((Booth_TBL[Tables Needed]>0)*(Booth_TBL[Company]=[@Company]),Booth_TBL[Booth Label],""))