TEXTJOIN cells unless a cell contain part of a string - google-sheets

I have several tables that represent rooms in our office, each table includes a column of few cells contain workers names and a device named like the following "Device A", "device B" etc.
Table 1:
HR G1:G6
George
Ema
Benjamin
Johanna
Device A
Table 2:
Dev H1:H6
Josh
Jenna
Tom
Jessica
Device B
I want to summarize all their names exclude the device to a cell on a new table.
Table 3:
Room
NAME A1:B3
HR
George, Ema, Benjamin, Johanna
Dev
Josh, Jenna, Tom, Jessica
The issue is that I can change the devices order so the names on the table can change often.
I want to use TEXTJOIN (or other tool) to combine all cells unless the cell includes "Device" in it, without specify exactly which one.
I tried to use REGEXMATCH, VLOOKUP, SEARCH, COUNTIF but they all return a list, so its not working well inside TEXTJOIN.
I've tried to use FILTER too but wildcard doesn't work there so I must provide the full name of the device.
Please your advice,
Thanks in advance!

You should be able to do something like
=textjoin(", ", 1, filter(G1:G6, not(regexmatch(G1:G6, "Device"))))
or
=textjoin(", ", 1, filter(G1:G6, left(G1:G6, 6) <> "Device"))
(Include the sheet name if you want the results to appear on a different tab).

Related

How To Determine Match from Multiple Cells in One Row

Editable Test Sheet:
https://docs.google.com/spreadsheets/d/1zKtE09TB-mAEQFRswity3R1ZGdYe7jq6ZYh_l4P398E/edit?usp=sharing
Although I believe what I'm trying to do is fairly simple, It is difficult for me to even find the correct words to describe what I'm trying to do. I suspect that is why I've been researching all day for an answer and cannot find it.
I need an ARRAYFORMULA that can check for the existence of a given "PARENT ID" in another table, but only if another cell in the same row is not true.
A given PARENT ID from TABLE 2 could appear in TABLE 1 multiple times, sometimes paired with "TRUE" and sometimes not. I only need to know if the PARENT ID from TABLE 1 appears in TABLE 2 along with the value TRUE in the "Done" column next to it. If it appears even once, I want to denote it in TABLE 2.
I am able to do this in various forms, but none of them work with ARRAYFORMULA.
See the shared example sheet above. I would greatly appreciate any help.
See my two newly added sheets ("Erik Help" and "Erik Help 2"). Below are the formulas I used:
In "Erik Help":
=ArrayFormula({"In Table 1 and Not Done?";IF(E3:E="",,IF(ISERROR(VLOOKUP(E3:E,TRIM(B3:B&C3:C),1,FALSE)),,TRUE))})
This delivers the results you want as asked (though your manually entered results did not list F3 as TRUE when I believe it should be).
The trick here is looking for the Parent ID within a virtual column that concatenates Col B and Col C and then TRIMs out extra characters (such as null). If there is an exact match, we know that there was no value in Col B. And since the only valid Col-B value is Boolean TRUE, we are assured that any match is in effect false (or not Done).
In "Erik Help 2":
=ArrayFormula({"In Table 1 and Not Done?";IF(E3:E="",,IF(ISERROR(VLOOKUP(E3:E,TRIM(B3:B&C3:C),1,FALSE)),,IFERROR("Item ID(s): "&VLOOKUP(E3:E,REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({FILTER(C3:C,A3:A<>"",B3:B<>TRUE)&"~",FILTER(A3:A&" (R"&ROW(A3:A)&")",A3:A<>"",B3:B<>TRUE)&","}, "Select MAX(Col2) GROUP BY Col2 PIVOT Col1"),, 9^9)),"~")),"[,\s]+$",""),2,FALSE),TRUE)))})
Instead of simply TRUE, this version returns the Item ID(s) that are not done for that Parent ID along with the row number where each incomplete Item ID is found.
Since you didn't expressly ask for this, I'm considering it bonus material and will not take time to explain it.
Another answer I received on another forum:
=ArrayFormula(IF(COUNTIF(C3:C&B3:B,E3:E),true,))
Credit to Prashanth KV

Google Sheets VLOOKUP formula stops working when new item values are added to the column being looked up

Hello stack overflowers.
I have recently been creating a nutrition tracker to better track and control my nutrition. However I have run into an issue. So currently I have a 1 sheet in the nutrition tracker which is a "database" of foods and their macro nutrients per gram. In this sheet, I will enter all the foods that I generally eat and their associated per G nutrients.
this food "database" sheet has the following columns.
FOOD NAME, CALORIES, PROTEIN, CARBS, OF WHICH SUGARS, FAT, OF WHICH SATURATED, FIBER, SALT
This database is then used as a reference, so that when I input each meal as I eat it, I can simply select the food from a drop down list and type the number of G in that meal, and the nutrients will all be calculated for me.
I currently have it setup so that I can select food from the drop down list generated by "foods" sheet, within each meal table I have created. This is then correctly filling in the rest of the columns as expected once I input a weight for each meal. There is however a huge problem.
As soon as the FOOD NAME column of the Foods sheet had values in it below row 7 (not sure why this row is the limit) the whole thing stops working, the data grabs based on VLOOKUP just return 0 and do not act as they are meant to. The strange thing is they work absolutely fine until I enter too many foods (7 foods) into the foods sheet.
Please find below a link to my spreadsheet, maybe you can duplicate it and play around a little yourselves to better understand the issue.
https://docs.google.com/spreadsheets/d/1orwih7s_Z4ew8G1vJcR6qlxyMpX8pqK-3Ynj42qQjcQ/edit?usp=sharing
(if you help me fix it, you will have a free nutrition tracking spreadsheet to help you take control of your diet aswell)
Thanks in advance.
In the June tab, clear all formulas in the range D11:K18.
Then enter in D11
=ArrayFormula(IF(LEN(B11:B18), IFERROR(VLOOKUP(B11:B18, FOODS!A:I, {2, 3, 4, 5, 6, 7}, 0)),))
This single formula will process all values entered in B11:B18.
Note the third parameter of VLOOKUP (set to false). If it is ommitted (as in your formula) it will default to 'true'. That means vlookup expects a 'sorted order' which may not be the case for your data.
References
VLOOKUP
try:
=INDEX(IF(B11:B18="";; IFNA(VLOOKUP(B11:B18; FOODS!A:I; COLUMN(B:G); ))))

Concatenate cells based on a condition

I look for the following: I have columns with part names that make up a particular product, where I inform if the parts are defective or not. When the part is OK the default information is set to "#". All defects have a depreciation value from 0 to 10.
I want to concatenate in one cell all the defects that depreciate the product. In another cell, the defects that do not depreciate.
Here's the test sheet:
https://docs.google.com/spreadsheets/d/1HX2eko7v15mDja6_KlajmUaHkY4SCmKfELvPxqgnDUA/edit#gid=0
Actually I got a solution, however, there are 18 columns and the formula will be very large. Could someone come up with a smarter solution?
Here's my current script:
=IFERROR(CONCATENATE(LEFT(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)<>0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)<>0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)<>0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)<>0;D2&", ";"");""));LEN(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)<>0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)<>0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)<>0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)<>0;D2&", ";"");"")))-2);".");"OK")
and
=IFERROR(CONCATENATE(LEFT(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)=0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)=0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)=0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)=0;D2&", ";"");""));LEN(CONCATENATE(IF(A2<>"#";IF(VLOOKUP(A2;$H$2:$I$5;2;FALSE)=0;A2&", ";"");"");IF(B2<>"#";IF(VLOOKUP(B2;$H$2:$I$5;2;FALSE)=0;B2&", ";"");"");IF(C2<>"#";IF(VLOOKUP(C2;$H$2:$I$5;2;FALSE)=0;C2&", ";"");"");IF(D2<>"#";IF(VLOOKUP(D2;$H$2:$I$5;2;FALSE)=0;D2&", ";"");"")))-2);".");"OK")
paste in D2:
=ARRAYFORMULA(REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
IF((A2:D<>"")*(A2:D<>"#"); A2:D&","; ));;999^99))); ",$"; "."))
paste in E2:
=ARRAYFORMULA(IF(B2:B<>""; IF(B2:B="#"; "OK" ; B2:B)&"."; ))
spreadsheet demo

Extract values from a range with 2 columns only if the value in column 1 contains a specific word in the column 2

I need to extract each individual person from a list that doesn't contain a certain activity (Project). Sounds easy but I can't quite get to the end of it.
Please check the example here on Sheet 2:
https://docs.google.com/spreadsheets/d/1qjbjXFCYj1qXrVVGNnhOj11asxT_o1xHWXerRqAl1UQ/edit#gid=2105763617
Here's the logic.
First I attempted to see if the individual only occurs once and if the Activity is not "Project"
=IF(A2<>"",IF(and(COUNTIF(A:A,A2)=1,B2<>"Project"),0,1),"")
Then I just extract the name that satisfies this criteria:
=query(ARRAYFORMULA(iF(I2:I=0,A2:A,"")), "where Col1 <>'' ")
This works, except there might be multiple assignments for the same person that does not contain the activity "Project" which my formula doesn't account for nor is it a simple dynamic arrayformula.
=UNIQUE(FILTER(A2:A, B2:B<>"Project"))
=UNIQUE(QUERY(A2:B, "select A where B <>'Project'", 0))
=UNIQUE(FILTER(A2:A, B2:B<>"Project",
NOT(REGEXMATCH(A2:A, "^"&TEXTJOIN("$|^", 1, FILTER(A:A, B:B="Project"))&"$"))))
While #player0's answer solves the question, it took a big performance hit on a sheet with >1000 rows.
Instead, I extracted all names that contained "Project" and then all names that did not contain "Project", then subtracted all the names from the first array to eliminate names that were in both.
=UNIQUE(FILTER(UNIQUE(FILTER(A2:A, B2:B<>"Project")), ISNA(MATCH(UNIQUE(FILTER(A2:A, B2:B<>"Project")), UNIQUE(FILTER(A2:A, B2:B="Project")),0))))
You may try this also:
{=IFERROR(INDEX($A$2:A$25,MATCH(0,IF($C$1<>$B$2:$B$25,COUNTIF($F$1:$F1,$A$2:$A$25), ""), 0)),"")}
N.B.
Cell C1 has criteria Project, using cell reference makes the formula
dynamic rather than hard coded.
Enter this formula in cell F2, finish with Ctrl+Shift+Enter,
and fill down.

Filter order data to rows

I need to make sheet that will contain each order code, address, quantity and dates in one row for each order code.
I have sheet "Data" with orders (Address ID, Product code, quantity and Order ID) and i need to put it in other sheet "Export" in specific order. Is there a way to do it with functions or script?
I made test spreadsheet so everyone can see preview of what i need: test sheet
For example i have Address ID A001, i need to get each code and quantity from this address ID and put in row, in test spreadsheet i made example.
Sorry if I am asking too much, but i need some help or advice :)
Made picture so it would be easier to understand:
picture
The operation you need is called "unpivot" and has a couple of possible solutions, some of them purely functional and some utilizing Google Apps Script. Search for "unpivot" to explore them. Here goes one of possible functional solutions. It is simplified compared to your precise needs because I am not sure which of your headers ("dimensions") are unique. I'm assuming here that only the product code and address id are unique, because it looks like this in the data.
Make a new worksheet and put the formula below in A1:
=arrayformula(
split(
transpose(
split(
concatenate(
arrayformula(Data!$A$5:$A & "|" &Data!$C$3:$G$3 & "\"
)
);
"\")
);
"|")
)
Then put another formula in C1:
=arrayformula(
vlookup(A1:A; Data!$A$5:$G; match(B1:B; Data!$C$3:$G$3; 0)+2; 0)
)
This will give you the rudimentary idea of how to construct first the list of all possible combinations of dimension values (Code, Address ID in this case) and then fill in possible dependent values using VLOOKUP. Then you can use more VLOOKUPS to add more columns as needed.

Resources