I need a system that allows to filters entries by different text tags.
Say we store info about some products. We have Red Apples, Pears, Watermelons, Cucumbers, Peppers and Bread. We store them in sheet named "Data" in column A. Next columns are occupied by tags, like Red Apples are Red, Sweet, Fruit, Unpacked; Peppers are Red, Spicy, Veggie, Packed; Bread is just Packed.
Then on another sheet we have a dedicated range, say A1:A10, which can accept any data tag, like Spicy or Packed. What I need is when somebody enters Spicy and Packed in this range, it looks up all items that are Spicy and Packed and displays them, so in this case it would display Peppers in B1 cell.
To recap: Data!A:A - entry names, Data!B:Z - tags, Main!A1:A10 - tags entered by user, Main!B:B - entries with tags, that correspond to those entered in A1:A10.
I was trying to use FILTER, but I can't figure out how to select proper condition ranges. I feel like this should be possible within this system and I really don't want to delve into scripting field.
This can be achieved using a helper column to collect all the tags and then a =query() formula.
1)
Start by creating a multi-tag column using either =join() or =textjoin(), capturing all the potential tags for each product.
2)
Then use this answer to help you create the =query() formula needed.
There is a pretty simple solution to this.
You would need to add a helper column and count how many tags does your item has from the listed ones, using this formula
=SUM(ARRAYFORMULA(COUNTIF(B1:1,'Main'!$A$1:$A$10)))
Next, in your presentation sheet reserve some place where you can enter tags - one at a time. In my case, it's range A1:A10. Then just paste this formula anywhere else
=IFERROR(FILTER(Data!$B:$B,Data!$A:$A=(10-COUNTBLANK($A$1:$A$10))),"")
At that place, all suitable elements will show up. I also added sorting to the formula, cause why not.
You can use more tags, for that just increase the tag range and edit formula so when there are no tags entered, COUNTIF gives 0.
if Data sheet looks like this:
and you need "constructive" list, you can do:
=SORT(FILTER(Data!A2:A, REGEXMATCH(TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99)),
TEXTJOIN("|", 1, A1:A10))))
spreadsheet demo
if you need a "destructive" list do:
=ARRAYFORMULA(SORT(QUERY({Data!A2:A, TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99))},
"select Col1 where "&TEXTJOIN(" and ", 1, IF(A1:A10<>"",
"Col2 contains '"&A1:A10&"'", ))&"", 0)))
Related
In my data sheet1, I want to use the 'Name in use' column (B) with the last two names with ARRAYFORMULA.
In my data sheet2, I want column (B) to be repeated with the same code next to the column A get filled
Please find the sample date sheet below https://docs.google.com/spreadsheets/d/1_AWRjexJNAcgNGsmrBKU_8JYL03UbAGeiyy4oI8B9fU/edit?usp=sharing
Regards,
Nimal PereraSri Lanka
Sheet 1
Your formula seems fine, just the ArrayFormula() needs tweaking. As noted in the docs, ArrayFormula() takes in a range, rather than a single cell.
You would have to do something like this:
=ARRAYFORMULA(IFERROR(UPPER(TRIM(RIGHT(SUBSTITUTE(A2:A5," ",REPT(" ",60)),120)))))
Essentially you type in the range you'd like it to apply on. So at any moment, instead of selecting a single cell for that row, you select the range. If you'd want to apply it to the entire column, use A2:A. You even did it right on sheet2
Sheet 2
Your names seem to be importing correctly once Sheet1 is done right. To have the same code everywhere, use something like this:
=ARRAYFORMULA(IF(LEN(A2:A),"SSD",""))
I have a a Google sheet which have multiple tabs in them
I use formula to get the consolidated info from the known names of the tabs as shown below
=UNIQUE({Appliances!A2:B;'Base, Trim & Crown'!A2:B;'Bathroom Accessories'!A2:B;'Bathroom plumbing'!A2:B;Cabinetry!A2:B;Carpet!A2:B;Closets!A2:B;'Entry Door'!A2:B;'Exterior and Interior Stone'!A2:B;'Exterior Lighting and Fans'!A2:B;'Exterior Siding'!A2:B;Fireplaces!A2:B;'Garage Doors'!A2:B;Gutter!A2:B;'Interior Door'!A2:B;'Kitchen Plumbing'!A2:B;'Paint Color'!A2:B;'Patio Stone'!A2:B;Roofing!A2:B;Slab!A2:B;Staircase!A2:B;Tile!A2:B;'Timbers, Beams & Ceilings'!A2:B;'Windows & Multislides'!A2:B;'Wood Flooring'!A2:B})
Suppose if I add a new sheet tab, this formula need to be updated again, which is cumbersome for me. So I am thinking is it possible to have a range in MASTER sheet that lists all sheetnames one below the other A2:A6 and synamically generate the sheet formula using indirect referencing?
So if I just add the new tab sheet name in MASTER the formula results are auto updated.
A2:A32 contains the list of sheetnames
=INDIRECT(CONCATENATE("{",TEXTJOIN(";",true,ARRAYFORMULA("'" &A2:A32 &"'!" & "A2:B")),"}"))
Well, first of all, INDIRECT doesn't work with ArrayFormula, sadly (I wish). But secondly, what's so cumbersome about updating the formula you have? Just format it like this:
=UNIQUE({
Appliances!A2:B;
'Base, Trim & Crown'!A2:B;
'Bathroom Accessories'!A2:B;
'Bathroom plumbing'!A2:B;
Cabinetry!A2:B;
Carpet!A2:B;
Closets!A2:B;
'Entry Door'!A2:B;
'Exterior and Interior Stone'!A2:B;
'Exterior Lighting and Fans'!A2:B;
'Exterior Siding'!A2:B;Fireplaces!A2:B;
'Garage Doors'!A2:B;
Gutter!A2:B;'Interior Door'!A2:B;
'Kitchen Plumbing'!A2:B;
'Paint Color'!A2:B;
'Patio Stone'!A2:B;
Roofing!A2:B;
Slab!A2:B;
Staircase!A2:B;
Tile!A2:B;
'Timbers, Beams & Ceilings'!A2:B;
'Windows & Multislides'!A2:B;
'Wood Flooring'!A2:B
})
Just add it where you want on the above list, leaving out the semicolon on the last item. (I'm not sure if you meant double quotes or not, so I left it as is.)
Or, if you really want to generate the sheet names from a list, you can use this, based on your above formula:
=ArrayFormula(TEXTJOIN(
";"&CHAR(10),
1,
"'"&SORT(FILTER(A:A,LEN(A:A)))&"'!A2:B"
))
which sorts in alphabetical order too. This outputs something you can copy+paste into your first formula.
I'm wondering if this is doable in Google Sheets.
I have product and ingredient list in a named range called Goods
I want to display a summary of what ingredients are needed in one cell. For example, I want the cell to say for 2 Wheat, 2 carrot.
So in natural language, I would like to look at the row, and if it has a value in it, then return that value and the header value, if it has 0 or null, I want to skip it.
Is this possible?
while there are various ways how to get partial ranges from Named ranges, in a long run it is more clumsy than not using Named ranges. but possible. for example to get headers:
=INDEX(Goods, 1, )
using INDEX, FILTER, QUERY, OFFSET, ARRAY_CONSTRAIN you can get various pieces of what you need.
alternative:
=ARRAYFORMULA(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
IF(E4:P10<>"", E3:P3&" "&E4:P10, )),,999^99))))
=ARRAYFORMULA(REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
IF(E4:P10<>"", E4:P10&" "&E3:P3&",", )),,999^99))), ",$", ))
I'm looking for a way to add together a dynamically generated list of ranges using (I'm guessing) an ARRAYFORMULA.
The normal way of attacking this is fine if there is a known list of ranges, the example of the results I want would work using this:
=ARRAYFORMULA( A1:A10 + B1:B10 )
In the case I'm after I want to add together ranges in multiple sheets. I don't want the users to have to manually adjust the array formula every time they add a new sheet to be calculated, and I also want to be able to add some logic to include or remove the particular sheet from the calculation, but for now I'm happy to ignore that and just focus on adding cells together.
My approach to this was to create a column with a list of names, each one matching a sheet in the document, and then using that list to dynamically build the list of ranges to add together, using INDIRECT.
.------------.
| sheet1 | <---- SheetListNamedRange
|------------|
| sheet2 |
`------------'
Here's a quick example
=ARRAYFORMULA( INDIRECT("'" & SheetListNamedRange & "'!D4:75") )
There are lots of failure modes depending on how it's done, but this particular formula only puts in the values of the first sheet and ignores any others, which I guess makes sense.
What I'm after is kind of the equivalent of i++ in a loop found in a normal coding language. Is there some way of making this work?
If I understand you correctly, you'd like to get a list generated based on different ranges across different sheets. If your case is as simple as the one you mention in the beginning of your post, the following would do the job.
={Sheet1!A1:A2; Sheet2!B1:B2}
If you want the sum of all these values, you can use SUM.
=SUM({Sheet1!A1:A2; Sheet2!B1:B2})
Please let me know if this isn't what you were looking for, so I can change the answer accordingly.
you can't refer to array of arrays in INDIRECT. you will need to INDIRECT each sheet which contains array.
=SUMPRODUCT(ARRAYFORMULA(INDIRECT(A1&"!"&"D:D")+
INDIRECT(A2&"!"&"D:D")+
INDIRECT(A3&"!"&"D:D")+
INDIRECT(A4&"!"&"D:D")))
note1: in this case result is 25 as sum of 10 + 15.
10 is sum of sheet1!D:D
and 15 is sum of sheet2!D:D
note2: there is no sheet3 and sheet4 which is equal to 0 in INDIRECT
note3: D:D of the sheet where you have the list of sheets needs to be empty
I would like to perform a multi criteria search of data in a column- contains data of check boxes(more than one option chosen).
For a clearer picture of what I am trying to do, screenshot below is a question in a form
Data from the form are saved in sheets like below,
So my concern here is if I would like to search/filter for the rows that contain "Commercial", the rows with Commercial,Engineering doesn't show up. That's definitely not an effective search.
Any advise on how can I go about this issue is kindly appreciated. If
Let's say you have your form in the response sheet in columns A to P, with the multiple choice in col D. If you want to filter your data on the word 'Commercial' you can either do:
=filter(A2:P, regexmatch(A2:P, "Commercial"))
or use query():
=query(A2:P, "select * where B contains 'Commercial' ")
Note: depending on your locale you may have to change the commas to semi-colons in order for the formulas to work.
I hope that helps ?
Following JPV's answer, I developed a line to make the query useful if you want to cross two categories. Let's suppose that someone in your checkbox example had picked all the options (IT, HR, Commercial, Engineering); and that you have created the cell with the dropdown option box in cell B1 with all your options, as JPV said.
Then, you want to filter and see all the people who had chosen IT and Commercial. You would, for that, create a second cell with the dropdown option box in, lets say C1; and then your query would be:
=query(A2:P, "select * where B contains '"&B1&"' and B contains '"&C1&"' ")
=FILTER(MOBILE!A2:E2000, ISNUMBER(SEARCH(A1,MOBILE!A2:A2000)))
SEARCH function will return a number of the position of the searched word (A1) in the searched strings in range (MOBILE!A2:A2000).
If the result of search is a number (ISNUMBER), then filter will return the TRUE rows result from the range MOBILE!A2:E2000.