How do I populate a cell based on multiple criteria in Google Sheets? - google-sheets

So here is the situation. I have one spreadsheet in Google sheets that has a column for the names of TV stations. I have a second column that lists airing times for ads. This is the format the date and times are in.
14-12-22 08:06:05
I have a second sheet that has the same column for TV station names. I also have a column that has a time range in the format
09:00-16:00
Then there is a third column for Rate.
What I am trying to do is add a Rate column to the first spreadsheet and populate that my matching up the TV Station name and the time range on the second sheet. My first thought was a VLOOKUP but I'm trying to match 2 conditions with the second one being a bit tricky since I am using an exact time vs a time range.
Any ideas?

As it is permitted to parse the time intervals I would recommend doing so (say with something like =SPLIT(A1,"-") since the results might then be arranged into a compact matrix such as shown in the image in ColumnsF:J. The differences in the rates for different stations at different times are readily apparent.
I have left the above in the same sheet as one with a representation of your other data since I (am lazy and) don't know the relevant sheet names anyway - but prefix the relevant sheet name (and !) to the column references in the formula that are later in the alphabet than C:
=vlookup(A2,F:J,match(C2,$G$1:$J$1,1)+1,0)
With extraction of the time element (into ColumnC) of your data (from ColumnA) the formula attempts to find the time from C in the first row, but accepts an inexact comparison by defaulting to the next lower value where there is no exact match. Once found, the MATCH() function returns the position of the match relative to the start of the range searched.
This is then used in a VLOOKUP() function to determine how far across to return the result of a search for the exact A column value in ColumnF.
Details of the syntax of the functions may be found via Help > Function list.

Related

Countifs function returns 0 in certain rows

I've recently started using Google Sheets for my new job and I need help with a little problem.
I created a function to compare a whole column of dates from a sheet with dates from another column on another sheet to filter the given count.
The code is as follows:
COUNTIFS('raw data'!$D$2:$D$952;">="&('2nd table'!$C$3:$C$52);'raw data'!$D$2:$D$952;">=01.08.2021";'raw data'!$D$2:$D$952;"<=31.08.2021")
raw data contains dates in column D. I've used 952 because that is the maximum range I can get. I've yet to solve how to implement this via named ranges.
2nd table contains the dates our employees started working at the company. I wanted to filter out the data that exists before their time at our company within raw data column D.
The function does return the correct value sometimes and sometimes it just returns 0.
If I boil down the function to just contain this:
=COUNTIFS('raw data'!$D$2:$D$952;">="&('2nd table'!$C$3:$C$52))
I get different values each time. I suspect that I cannot use the function in this way because the 2nd table got a different amount of rows to compare from.
How can I work around this issue if that's the problem and why does the function even work sometimes?

In google sheets extracting words from column based on reference column

In this scenario, I have a reference column (A) of 6 types of devices, and a second column (B) of several thousand specific device names including the word from the reference column in the string.
I am trying to extract into a new column (C), from the column B just the relevant word from the string that corresponds to the reference column.
So far have been unsuccessful in finding the right working formula.
You can use VLOOKUP function to search particular data and get desired result.

Compare data google sheets

I am using google sheets and I want to compare the quantity of interactions o a given person in a period of time.
My problem is that between one week and another, the people can change, some people can have no interactions and is not reported and I can have new people.
So I need a formula that allow me to compare the previous period of time but also the name.
I am trying this in order to follow up how the people's behavior is changing.
This is the example spreadsheet.
Thanks
This is an easy, quick-and-dirty solution using vlookup.
There are two variations. One using a single criteria and one using multiple criteria. infoinspired.com has a good article on How to Use VLOOKUP with Multiple Criteria in Google Sheets.
Single Criteria: This is the formula.
=iferror(vlookup((B2+1)&C2,$A$2:$D$9,4,false),"error")
This involves a cheat by creating a new column A which contains the concatenation of the date and name values for each row. This is a unique value.
The lookup criteria is the (date (B2) plus 1=the next day) and the name.
The lookup range is self-explanatory and the value returned is the Quantity (from column 4).
The vlookup formula is inside an iferror() so that any problems are highlighted.
Multiple Criteria: This uses an array formula.
=ArrayFormula(iferror(vlookup((B2+1)&C2, {B2:B&C2:C, D2:D}, 2, 0 ), "error"))
The vlookup component is very similar to the "simple" formula. The difference is that each criteria 1:(Date plus 1) and 2:Name are recognised separately, and assigned discrete lookup columns (B and C respectively).
Again, the whole thing is wrapped in an iferror statement to highlight any problems.
This spreadsheet shows the workings:

How to get last value of column in multiple sheets and add them together

I'm currently trying to get the last value of Column "D" in several sheets, then add all the values together, then calculate a percentage based on a value from a main sheet cell.
I can get =VALUE(D:D) to work and =VALUE(Animations!D15), but not a combination of both which is what I need (since the size of the column will continue to grow).
It would be best if it was the last numerical value in column D, and not account for blank spaces or strings.
Thanks!
To find the last populated number in a column use Index with an approximate Match to 1E+99.
=index(sheet2!d:d, match(1e99, sheet2!d:d))
The above retrieves the last number in column D on Sheet2.
Google sheets will not process an array of worksheet names through INDIRECT like Excel will but a 'helper' column will take care of that. If you want to hard-code a series of worksheet names into a sum of index/match formulas, then Indirect isn't even necessary.
In the accompanying linked worksheet, I've used this method to retrieve the last number from columns with numbers, text and errors. I've thrown in the 'last number' cell address as well.
Linked spreadsheet

Google Spreadsheets: Use row of nth occurrence of value for other calculations?

I am using a combination of Google Forms and Google Spreadsheets for data entry and interpretation for scouting in a robotics competition (FRC). The user fills out a form for each match with the data from 6 different teams. That data is put into a spreadsheet by the form, and the sheet of data is used by other sheets for interpretation, and it outputs different stats.
One of the sheets is designed to show the progression of the team's stats over the course of their 9-10 matches. I want it to show the values for a certain stat in the same order as the matches that they played (Match 1: 10 points; Match 2: 15 points; etc.). The problem is that there are upwards of 40 teams, so teams don't play back-to-back. I am trying to create a function that searches for the nth occurrence, by row, in the 6 columns that contain team numbers. That function would then use that row to return a value for a stat by that team from that match.
My spreadsheet is here. The sheet of raw data is called "Games", and the sheet containing the progression data is called "Over Time". Within the "Games" sheet, each line is a match, and there is data for each of the 6 teams in each line. Each team gets a line on the "Over Time" sheet, and each stat would take up about 10 columns.
The function would search for the nth time (as specified by the number in row 2) that the team number (as specified in column A) occurs. It would then search that row number for the team number and return the value in the column specified by the function (eg. If the team number occurs in column C, return the value in column E of the same row.). In the sheet "Averages", I used mainly SUMIF and COUNTIF functions to return averages for each stat, but I can't figure out how to use the array functions that would be necessary for the first step of this function. I would prefer to avoid using hidden columns and rows, as that just gets messy, so it would be great if the entire function is in one cell. I would also prefer it to be a function, as opposed to a script.
This solution uses one function per row (not one function for the entire table). In 'Over Time'!B3:
=ArrayFormula(SPLIT(CONCATENATE(REPT('Games'!E$2:BW&CHAR(9);('Games'!C$2:BU=A3)*(MOD(COLUMN('Games'!C$2:BU$2);14)=3)));CHAR(9)))
which can be filled down to B8.
If it is absolutely necessary to have one formula for the entire table, then I'm sure it could be done, but it will be horribly complex. Further, as it is, these "concatenate then split" type formulae (which you need to resort to when the data isn't nicely vertical) are quite inefficient, depending on how big your source data gets. That may not be an issue in your case, but for big source data sets, I would prefer a custom function for performanc ein this case.

Resources