Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 months ago.
Improve this question
I have done some digging and I haven't found the solution to my problem. To be honest I don't know the "keywords' to search to find the solution to this problem.
I have a list of names in a in one sheet2.
I want to scan a column with that person's name at the top in sheet1. every time the number "1" appears in that column I want to write the text (Course name) from that row. The number 1 will appear up to 7 times.
I have tried vertical lookup and if statements but not getting what I need.
A picture is worth a thousand words I guess.Sheet1 Sheet 2
Assuming your data are in the cells below on Sheet1 (it's impossible to be sure between your having merged cells, and no row labels visible):
I believe this is what you want for Sheet2:
The formula in cells C2:C6 of Sheet2 is
=TRANSPOSE(filter(Sheet1!$B$8:$B$16,INDEX(Sheet1!$I$8:$K$16,,MATCH(B2,Sheet1!$I$4:$K$4,0))))
The formula below
=filter(B8:B16,I8:I16)
if entered on Sheet1 would result in a vertical range comprising BIOLOGIE 11, and BUSINESS TECHNOLOGY 11, i.e. entries from B8:B16 where the rows have a 1 in the I8:I16 range.
Since there are several students, the I8:I16 range must be determined dynamically; this is why the INDEX() and MATCH() functions are used.
The INDEX() function is used to a return a component of the range used as it's first argument, i.e. part of the Sheet1!$I$8:$K$16 range, as that is where the 1s/blanks for the 3 (visible) students reside (you will have to widen it for your actual data).
The INDEX() function can take 2 additional arguments, being the row number and column number of the cell (within Sheet1!$I$8:$K$16) that we want returned. While both of these arguments can be supplied, only one is mandatory - in this context, the row argument is skipped, and only a value for the column is supplied: this means that the component of Sheet1!$I$8:$K$16 that we want return is an entire column (i.e. all the rows for that column).
The MATCH() function is what is used to determine the column, i.e. it identifies the position, of the current student's name, within the Sheet1!$I$4:$K$4 range (the 3rd argument, 0, to the MATCH() function means that we want an exact match; again you will have to widen this range for your actual data).
In this way the INDEX() and MATCH() functions combined identify the column of 1s/blanks appropriate to the current student; this then forms the second argument to the FILTER() function, so that it can return the subjects appropriate to the current student.
Finally, the TRANSPOSE() function is used because you want the results populated horizontally whereas, by default, the FILTER() function returns a vertical range.
Related
I am trying to format a cell based on multiple conditions. I am creating a spreadsheet to keep track of items borrowed. Let's say I am lending books. I want to have a list of books, one name in each cell. Then below that I want to have 3 columns: One column to enter the name of the book borrowed, the borrowing date, and the return date. I want to turn the cell with the book name RED, if the book has been borrowed AND if the return date is BLANK, meaning book is out. In my example screenshot, cell A2, and B2 should be red.
The conditional formula I have come up with is =AND($A6=A2, $C6="") for Book1 conditions, but it only works if C6 if empty, not if C8 is empty or other cells in column C where Book1 is found AND the return date is blank. There is no specific deadline to return items, just that if book has been borrowed and the return date in the same row is empty then the book name at the top should turn red.
Compare the result of COUNTA applied to the in and out ranges.
E.g. COUNTA(FILTER($B6:$B,$A6:$A=A2)) will count how many times a specific book is checked out, while COUNTA(FILTER($C6:$C, $A6:$A=A2)) will count how many times it is checked back in
Your question title asks about "multiple conditions", but very specifically you're looking to match based on any row that itself matches multiple conditions. That goes beyond the common AND operator and into a function that can process a range. You also need to be prepared for a book to be checked out and returned many times, which means there's no single row that manages the status of a given book; VLOOKUP and INDEX/MATCH are off the table too. Instead, you're effectively looking to generate a list of 0 or 1 values that match whether that book was checked out without being returned, and then coloring the cell based on whether there are any rows that match that condition.
To operate on multiple values at a time, you can use ARRAYFORMULA and then combine the output array with OR. However, one of the tricks about ARRAYFORMULA is that, to preserve the invariant about making single-value functions into array-valued functions, you can't use functions that can take arrays. This means that AND and ISBLANK don't work the way you'd like them to, but you can resolve that by using * instead of AND and = "" for ISBLANK.
One such solution (working example):
=OR(ARRAYFORMULA((A1 = $A$5:$A) * ($C$5:$C = "")))
ARRAYFORMULA isn't the only function to operate on a list of values, though; you could also use FILTER directly to only return matching rows. Here, you're checking whether any row has a matching book name and a blank return value, and then confirming that the value is not the #N/A that FILTER returns when nothing matches.
One such solution (working example):
=NOT(ISNA(FILTER($A$8:$C, $A$8:$A = A1, $C$8:$C = "")))
Of course, you can also take advantage of the fact that you're only checking blanks to use tehhowch's solution with COUNTA and FILTER above. However, since that solution won't work for arbitrary expressions, you can use ARRAYFORMULA or FILTER if your needs become more complex.
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.
I have a sheet where the columns are months in a year and the rows are various metrics. Every month, we add another column on the right.
I need something that I can give a ROW and it will always return the right most value. That is, it automatically updates whenever we add a column for a new month.
There's a few ways of doing it, but one way (considering row 2 in this example):
=FILTER(2:2,COLUMN(2:2)=MAX(FILTER(COLUMN(2:2),LEN(2:2))))
I was very happy to have found #AdamL's answer and it did make my day, but I have since found a simpler way that works fine for my data sample, and that is using the LOOKUP function.
The LOOKUP function will look for a certain value in a given range, but if you pass it a humongous value, a value that is over your data range, it returns the last, rightmost value by default.
The answer is then very simple, just pass it the range - or row if that's what you need - and a huge value (many people do this using the biggest number that Excel can handle, but Google sheets is not Excel, and since I don't know what is the biggest number Google sheets can handle, I'll just give it a value well outside of my data set). Assuming you need to lookup into the entire row number 2:
=LOOKUP(999999999,2:2)
And that's it.
This function will throw an error if there isn't any data, so if you (like me) need to get that particular value only if it exists, you can combine this with a simple IF function:
=IF(ISERROR(LOOKUP(999999999,2:2)),"EMPTY",LOOKUP(999999999,2:2))
You can replace the string "EMPTY" with any value or function you want in there if the LOOKUP function returns an error.
I hope this simpler method is of any help, and thanks again to #AdamL for his original answer.
Adding this one for future readers. The formula I found years ago for obtaining the rightmost value was:
=index(2:2,1,COUNT(2:2))
However for each blank cells in amongst the cells with data, the returned value is the Nth last value (2 blank cells in row 2 and the formula will return the 3rd last value from the right, not the rightmost value). It appears to work, but won't be accurate in all cases.
As such, I do not recommend this formula as you can not depend on it if ever there will be an empty cell before the right-most within your data.
I'd like to quickly include or exclude an entire range of values in a SUM.
Presently I'm SUMing select cells for a grand total: [E19] =SUM(E13,E20,E30,E45,E55,E70,E80)
These are in turn SUMs of selected ranges:
... [E30] =SUM(E31:E44), [E55] =SUM(E56:E69), ...etc.
One of these ranges I would like to toggle it's inclusion in the Grand Total.
It seemed the best way to do it was this:
[E45] =SUMIF(D45,"☑",E46:E54)
In short, in cell E45 I'd like to SUM E46 to E54 only if D45 contains a ☑.
However Google Doc's SUMIF seems to only work with matched ranges: =SUMIF(D46:D54,"☑",E46:E54)
Is there a way to SUM a range only if a specific value exists in a single cell?
You're right about SUMIF, it allows you to sum values from a range, which meet a certain criteria (on another range of the same length). For example, if you had two columns called "status" and "price", you could use it to sum all the prices for a given status.
What you're trying to do can be done, instead, with the use of the IF function:
=IF(D45="☑";SUM(E46:E54);0)
If the condition specified in the first argument is true, it will return the second argument, that is, the sum. Otherwise, it will return the third argument, 0.
After working through the logic to share the issue I wound up identifying a solution. Rather than trying to force SUMIF to check a single cell against a range. I just nested the 1:1 SUMIF inside my 'Grand SUM': =SUM(E13,E20,E30,SUMIF(D45,"☑",E45),E55,E70,E80).
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.