Count specific words in table for each row that begins with a cell of a certain value (Google Sheets) - google-sheets

That's about as clear as I make what I'm trying to do in Google Sheets.
Here's a sample table with two tabs.
Tab 1
Basically, I've got a table fed from a form. One column has names of say 50 various people. The names repeat randomly.
Other columns contain comments that each person made.
Tab 2
Here is essentially a heat map of keywords used by the different people. Column A are the keywords, while row 1 contains the keywords I'm interested in.
Each cell in this grid should (1) search tab 1 for all instances of each name, then (2) count the number of times the keyword appears in all of that person's comments.
Countifs doesn't work because the array arguments are different sizes.
I can't figure out how to phrase a filter embedded in a countif.
And using QUERY seems like it will cause trouble because my actual spreadsheet is something like 100 names and 40 keywords.
I'm open to suggestions and grateful for your help!
ken.

In B2 try
=sum(ArrayFormula(--regexmatch(filter(Sheet1!$B$2:$F, Sheet1!$A$2:$A=B$1), "\b"&$A2&"\b")))
Then fill down to the right and down as far as needed.
To make the match case-insensitive, change "\b"&$A2&"\b" to
"\b(?i)"&$A2&"\b"
See if that works?

Related

Querying helper table within Google Sheets

I want to import central banks interest rates into google sheets. The table I'm using can be found here:
=importhtml("https://www.investing.com/central-banks","table",1)
For each items that I want from this table, I would have a function like (in this example, to fetch 1.00%):
=value(substitute(index(importhtml("https://www.investing.com/central-banks","table",1),2,3),",",""))
If I need this whole table, which consists of 12 rows (excluding header) x 4 columns, I would have 48 such formulas. It seems to me that:
this is messy, and
making 48 calls to the investing.com URL where one could probably suffice.
So I decided to try a different approach. In another tab of my google sheets, I call the whole table:
In my other tab, I thought to query this table (assume it is in a tab called rates) instead. But I don't know how. Is there a way, and if so, what is the correct way to query say:
the first name in the table (Federal Reserve (FED))?
the fourth interest rate in the table (-0.75%)?
Any help is greatly appreciated.
To get 1%, try
=index(importhtml("https://www.investing.com/central-banks","table",1),2,3)
index
adapt parameters to fetch
the first name in the table (Federal Reserve (FED)) =index(importhtml("https://www.investing.com/central-banks","table",1),2,2)
or the fourth interest rate in the table (-0.75%) =index(importhtml("https://www.investing.com/central-banks","table",1),5,3)
To get all % per banks at once
=query(importhtml("https://www.investing.com/central-banks","table",1),"select Col2,Col3",1)
The answer he gave you Mike Steelson is good, but if I were you, I would make it in such a way that I could change the parameters at any time
=query(importhtml("https://www.investing.com/central-banks","table",1);"select Col2 WHERE (Col3='"&$A1&"')",1)
where A1 = 1.00% or any number entered into that cell

Google Sheets Count Unique Dates based upon a criteria in different columns

I am trying to find a formula that will give me the count of unique dates a persons' name appears in one of two different columns and/or both columns.
I have a set of data where a person's name may show up in a "driver" column or a "helper" column, multiple times over the course of one day. Throughout the day some drivers might also be helpers and some days a driver may come in for duty but only as a helper. Basically all drivers can be helpers, but not all helpers can be drivers.
I've attached a link to a sample sheet for more clarity.
https://docs.google.com/spreadsheets/d/1GqNa1hrViX4B6mkL3wWcqEsy87gmdw77DhkhIaswLyI/edit?usp=sharing
I've created a REPORTS tab with a SORT(UNIQUE(FLATTEN)) Formula to give me a list of the names that appear in the DATA Tab.
I'm looking for a way to count the unique dates a name from the name (Column A of the REPORTS Tab) appears in either of the two columns (Column B and/or C of the DATA Tab) to determine the total number of days worked so I can calculate the total number of days off over the range queried.
I've tried several iterations of countif, countunique, and countuniqueifs but cannot seem to find a way to return the correct values.
Any advice on how to make this work would be appreciated.
I think if you put this formula in cell b7 you'll be set. You can drag it down.
=Counta(Unique(filter(DATA!A:A,(DATA!C:C=A7)+(DATA!B:B=A7))))
Here's a working version of your file.
For anyone interested, Google Sheets' Filter function differs slightly from Excel's Filter function because Sheets attempts to make it easier for users to apply multiple conditions by simply separating each parameter with a comma. Example: =filter(A:A,A:A<>"",B:B<>"bad result") will provide different results between the Sheets and Excel.
Excel Filter requires users to specify multiple conditions within parenthesis and denote each criterion be flagged with an OR condition with a + else an AND condition with a multiplication sign *. While this can appear daunting and bizarre to multiply arrays that have text in it, it allows for more flexibility.
To Google's credit, if one follows the required Excel Syntax (as I did in this answer) then the functions will behave the same.
delete what you got and use:
=QUERY(QUERY(UNIQUE({DATA!A:B; DATA!A:A, DATA!C:C}),
"select Col2,count(Col1),"&D2&"-count(Col2)
where Col2 is not null
group by Col2"),
"offset 1", 0)

How do I compare two (not identical) tabs (or sheets) for differences in a specific column

I have two database dumps in Google sheets. They contain several thousand entries - many are identical, but not all. I now need to find all of those where a number in a specific column has increased by a certain number. The problem is that the rows not necessarily are the same, as entries in the database can have been deleted - and more been added, so rows do not add up.
I have tried various forms of 'if' and 'query' - none that have brought me closer to a solution.
I'm thinking that I first need to compare the column where the unique id is to ensure that it is the right entry that is being compared.
I would like to completely automate this, but a semi-manual way of doing this could also be okay.
One solution for this could be to get Google to check the unique id's of the two tabs - and then display the content of a second column in the first tab only where the id's can be found in both tabs.
I just cannot get Sheets to do this.
Any help would be appreciated
if I understood you right you can use filters for your task. For example
=FILTER(YourSheet1!B$2:B;YourSheet2!A$2:A=C2;YourSheet2!D$2:D=E2)
It will return you the line, where A$2:A == C2 and D$2:D == E2 from sheet two. So you can using filters choose data that has equal column values. If there exist copies it will return an error to the cell
Found the solution... A simple LOOKUP was what I needed:
=LOOKUP(B147,stats23Dec!B:B,stats23Dec!G:G)

Google Sheets Formula for Pulling Specific Values in Two Ways

I'm trying to do a couple of different things with a spreadsheet in Google and running into some problems with the formulas I am using. I'm hoping someone might be able to direct me to a better solution or be able to correct the current issue I'm having.
First off all, here is a view of the data on Sheet 1 that I am pulling from:
Example Spreadsheet
The first task I'm trying to accomplish is to create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. This sheet would be used to import the data via a CSV into our calendar system each month. I tried doing an Index-Match where it used the date to pull the associated values however I found that I had to keep adjusting the formula offsets in order to capture new information. It doesn't seem like Index-Match works when multiple rows/columns are involved. Is there a better way to pull this information?
The second task I am trying to accomplish is to create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). However, I run into the same problem here because for each new row I have to change the formula to reflect the correct information otherwise it doesn't pull the correct cell when it finds a match.
I would appreciate any and all information/advice on how to accomplish these tasks with the formula combination I mentioned or suggestions on other formulas to use that I have not been able to find.
Thanks in advance!
Brandon. There are a few ways to attack your tasks, but looking at the structure of your data, I would use curly brackets {} to create arrays. Here is an excerpt of how Google explains arrays in Sheets:
You can also create your own arrays in a formula in your spreadsheet
by using brackets { }. The brackets allow you to group together
values, while you use the following punctuation to determine which
order the values are displayed in:
Commas: Separate columns to help you write a row of data in an array.
For example, ={1, 2} would place the number 1 in the first cell and
the number 2 in the cell to the right in a new column.
Semicolons: Separate rows to help you write a column of data in an array. For
example, ={1; 2} would place the number 1 in the first cell and the
number 2 in the cell below in a new row.
Note: For countries that use
commas as decimal separators (for example €1,00), commas would be
replaced by backslashes () when creating arrays.
You can join multiple ranges into one continuous range using this same
punctuation. For example, to combine values from A1-A10 with the
values from D1-D10, you can use the following formula to create a
range in a continuous column: ={A1:A10; D1:D10}
Knowing that, here's a sample sheet of your data.
First Task:
create a sheet that lists all of these shift days with the date in one
column and the subject ("P: Ben" or S: Nicole") in another column.
To organize dates and subjects into discrete arrays, we'll collect them using curly brackets...
Dates: {A3:G3,A7:G7,A11:G11,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
This actually produces two rows rather than columns, but we'll deal with that in a minute. You'll note that, because there are two subjects per every one date, we need to effectively double each date captured.
Dates: {A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
Still with me? If so, all that's left is to (a) turn these two rows into two columns using the TRANSPOSE function, (b) combine our two columns using another pair of curly brackets and a semicolon and (c) add a SORT function to list the dates in chronological order...
=SORT(TRANSPOSE({{A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15};{A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}}),1,TRUE)
Second Task:
create a new tab which lists all the dates a specific person is
assigned too (that way this tab will update in real time and everyone
can just look at their own sheet to see what days they are on-call).
Assuming the two-column array we just created lives in A2:B53 on a new sheet called "Shifts," then we can use the FILTER function and SEARCH based on each name. The formula at the top of Ben's sheet would look like this:
=FILTER(Shifts!A2:B53,SEARCH("Ben",Shifts!B2:B53))
Hopefully this helps, but please let me know if I've misinterpreted anything. Cheers.

match values from a range into each row of a table in Google Sheets

I've been working on a multi tiered drop down program, and in filtering one of the tables I stumbled upon a problem I can't find any help on.
Basically, I have 2 sheets. Sheet1!A2:A has a set of values. In this example, A2=110, A3=114, A4=162. However, with each use of the program, there could be any number of values and the values could change.
In the second sheet, Sheet2! there is a table. The first row has the headers that I want to return from my search. Under each header is a series of numbers ranging from 3 to well over 50 values. And the number of columns is also unknown...(it will keep getting larger).
So I want to know which columns have all 3 values from Sheet1!A2:A in them.
Column 3 might have 6 numbers (95,110,114,125,150,162) and column 7 might have (80,110,114,125) so I would want to return the header from Column 3 but not from column 7.
Does any of this make sense? Again in simple terms, I want to query all of the columns in Sheet2 to see which contain all of the values from Sheet1!A2:A
Any help would be so greatly appreciated...
-Daniel
I set up an sheet using your example data:
https://docs.google.com/spreadsheets/d/169VrbWkTlRMzhNPe4G8hQL1MdfqQuTvjb87aRD9hiWo/edit#gid=1923440782
I've restricted the formula in cell D2 to 500 rows for the sake of speed but you can remove the references to make it work across the whole sheet:
=FILTER(Sheet2!1:1,ArrayFormula(TRANSPOSE(mmult(TRANSPOSE(COUNTIF(A2:A500,Sheet2!A2:Z500)),TRANSPOSE(split(rept("1,",COLUMNS(TRANSPOSE(COUNTIF(A2:A500,Sheet2!A2:Z500)))),",")))=count(A2:A500))))

Resources