Compare data google sheets - 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:

Related

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)

Formula for looking up and filtering data from a sheet

I want to do a complex formula using google sheets:
I have a list of place that will be visited by different people.
Some places are not to be visited, marked with /
Some places need to be assigned, marked with ?
Wanted outcome:
A list of cells that changes every day automatic.
An overview of who is going where that day and what needs to be assigned.
So I need a formula that can select a row based on today() and then filter out Persons in that row. Then for each person, another formula that looks up the first row in the table and puts duplicates together.
Example:
Wanted outcome:
Link to excel file, but it needs to work in google sheets too: xlsx
My solution is not the most elegant but it does the job.
First I build a column with date and unique persons or ? in this column:
=unique(sort(transpose(index(A1:H10,match(today(),A1:A10,0)))))
Then I find Places corresponding to these persons (I use filter function for it and then I use textjoin to keep them in single cell).
The formula is copied down as filter function does not accept a range and arrayformula as a filtering criterium.
My solution is available here:
https://docs.google.com/spreadsheets/d/1GTy_UaFP8LbA8OLnEhT_R_twpDCIWCuvQfBAigqtbR0/copy

How to apply arrayformula to a series of columns

I'm trying to make a spreadsheet to track membership for an organization.
Basically my design is an input sheet with columns of names associated with expiration dates, then another sheet that collects all the unique names and all of their associated expiration dates, and then one last sheet that filters the names into only those with expiration dates in the future.
I am able to collect all the unique names into one column using an arrayformula, but I am stuck trying to do a lookup operation of some kind that, for each name, will look for the name in each column and if it appears then it will add the associated expiration date to it's list (and otherwise add a blank cell, and then I can filter out the blank cells).
Is there a way to use vlookup or anything else in an arrayformula to do a series of operations for all columns in a range? Also, I want to use arrayformula because I want the formula to be infinite so the spreadsheet can keep growing. I've tried using
=ARRAYFORMULA(IF(ISERROR(VLOOKUP(A1:A,Sheet1!A2:200,1,FALSE)),,Sheet1!A1:1))
But vlookup, and anything else I tried like match, interprets Sheet1!A2:200 as a single range and performs a lookup only in the first column and does not do a separate lookup in each column.
For example, I might have this input on Sheet1
And want this result on another sheet
I suspect the combination of what you would really like and what is reasonably practical is a script but the following is an array formula, though would be cumbersome to extend and does require copying down (from B1):
=split(if(ISERROR(match(A1,Sheet1!A:A,0)),"",Sheet1!A$1)&"|"&if(ISERROR(match(A1,Sheet1!B:B,0)),"",Sheet1!B$1)&"|"&if(ISERROR(match(A1,Sheet1!C:C,0)),"",Sheet1!C$1),"|")
Assumes a unique list of names in ColumnA, such as created by:
=unique(QUERY({Sheet1!A2:A6;Sheet1!B2:B6;Sheet1!C2:C6},"where Col1 is not NULL"))
in A1.

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.

How do I populate a cell based on multiple criteria in 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.

Resources