Know first match of COUNTIFS in Google Sheets - google-sheets

I have a formula that counts rows with two conditions.
=COUNTIFS(CITY!A2:A3000;"<>";CITY!D2:D3000;"")
Now, my purpose is to know the first cell that matches the conditions (i.e. A2,A25,A56,etc...).
I.e:
Date (A) | Location (B) | Teacher (C)
=======================================
16/12/2020 | Spain | Luis
--> 17/12/2020 | |
17/12/2020 | Spain | Luis
Cursor goes to B2 because Date file is not empty and Location is empty
Can you help me?

try:
=INDEX(HYPERLINK("#gid=0&range=A"&MIN(IF((B2:B="")*(C2:C=""), ROW(A2:A), )), "jump"))

Related

Reference range when column matches string

Budget spreadsheet. Column A contains categories, Row 1 contains paycheck dates, and each cell from B2:AE91 contains numeric values ("how much I spent on categoryX during paycheckY").
Named ranges:
Column A - "Budget_LineItem"
Row 1 - "Budget_PayPeriods"
On another tab, I have a list of specific categories called "Funds," where I want to track how much I've saved so far each paycheck toward the category by adding up the category's values each paycheck up until TODAY().
For example:
| | A | B | C | D |
| - | - | - | - | - |
| 1 | Fund | Balance | Today: | =TODAY() |
| 2 | Auto Insurance | =SUMIF(Budget_PayPeriods,"<="&MAX($D$1:$D$2),Budget!F48:AE48) | Projected Date: | |
As you can see, I just have a static range for the "Auto Insurance" category: Budget!B48:AE48. This works, but I want a formula that looks up the adjacent value in column A against the Budget_LineItem range, and returns the row range from B:AE in the Budget spreadsheet.
Basically reads: "Go find how much I've saved/spent so far toward categoryX in the Budget tab, and add up all the values for each paycheck up through today."
I know I'm close, but I can't make INDEX, MATCH, or any of the LOOKUP functions do what I need. I just can't figure it out.
EDIT: Here's a link to an example: https://docs.google.com/spreadsheets/d/1L4mlMrRCWwDNPSiYHpmFiXU1zNOnga6gAziz_m2awKI/edit?usp=sharing
I also made a change to the OP formula in B2 as I realized it didn't work. I had tweaked it because my original formula had extra complexity and I was trying to KISS for this question. I changed it back to the more complex version so it works properly now.
delete range B2:B and use this in B2:
=INDEX(MMULT(FILTER(Budget!B2:4, Budget!B1:1<=MAX(D1:D2))*1,
SEQUENCE(SUMPRODUCT((Budget!B1:1<=MAX(D1:D2))))^0))
update:
=INDEX(IFNA(VLOOKUP(A2:A,
{Budget!A2:A4, MMULT(FILTER(Budget!B2:4, Budget!B1:1<=MAX(D1:D2))*1,
SEQUENCE(SUMPRODUCT((Budget!B1:1<=MAX(D1:D2))))^0)}, 2, 0)))

Combining multiple columns into single range

I have a sheet with several lists of names like such:
A | B | C
Joe | Steve | Mike
Steve | Dave | Alex
Sarah | Mike | Joe
Beth | Jane | Steve
I'm trying to consolidate all the names in those columns down to a single range (such as can be used by unique()) so that users can be selected from a dropdown.
Adding a multi-column range to unique() returns a multi-column result based on the uniqueness of each multi-column row (i.e. if 'Sarah, Mike, Joe' above were repeated, that would filter down to a single entry in the results)
=UNIQUE(FILTER({A1:A;B1:B;C1:C},{A1:A;B1:B;C1:C}<>""))
=UNIQUE(TRANSPOSE(SPLIT(TEXTJOIN(" ",1,TRANSPOSE(QUERY(TRANSPOSE(A:C),,50000))), " ")))

show all results on VLOOKUP

On Google sheets I wish to correlate data from a column, every time its adjacent column has a certain attribute.
For example, Imagine I have a list of pupils and the language that they are studying. In column A is the name of the pupil and in column B is the language:
NAME | LANGUAGE
---------------------------------------------------
John | French
James | Spanish
Stephen | Spanish
Simon | German
Mark | French
Luke | German
Robert | French
I want to generate a new sheet showing the name of each language, with the names of the people who study it in the adjacent columns. It would look something like this:
LANGUAGE | NAMES
---------------------------------------------------
French | John | Mark | Robert
German | Simon | Luke |
Spanish | James | Stephen |
I have tried to achieve this with VLOOKUP however this only returns the first value encountered for each language, rather than all the values.
What is the best way to achieve this?
Assuming 'French' is in cell A2 of Sheet2, in B2 you could try something like
=transpose(filter(Sheet1!$A$2:$A; Sheet1!$B$2:$B=$A2))
and fill down.
(change ranges to suit).
Try QUERY which is so powerful with transpose added too:
=TRANSPOSE(QUERY(Sheet1!A2:ZZ, "SELECT A WHERE B = '"French"'"))

Google Sheets: How to eliminate duplicates in some columns and show only the most recent data in others?

I have a spreadsheet of books, with one row for every time a book was checked out (this is a small classroom library). Here are the columns:
BookTitle | Author | DateCheckedOut | CheckedOutBy | Status
=========================================================================
The BFG | Dahl, Roald | 6/1/2016 | Suzy | Out
The BFG | Dahl, Roald | 4/5/2016 | Johnny | Returned
The BFG | Dahl, Roald | 12/4/2015 | Wendy | Returned
Charlotte's Web | White, E.B. | | | Added
Wonder | Palacio, R.J. | 5/29/2016 | Joey | Returned
Wonder | Palacio, R.J. | 3/21/2016 | Mary | Returned
I want to query it to get only the row with the highest date value for each book and then display all columns of that row except CheckedOutBy.
I wanted to get a list of unique book title / author combinations and then join it with the original table the way I would in DB2, but it seems that joins like that are not possible in Google Sheets. I tried grouping and the max function, but when I get those things to work I either haven't been able to eliminate earlier dates or haven't been able to display columns that aren't being used in the aggregate function. My Google Sheets querying skills are not up to par :/
Is there a simple way to do this that I'm missing? I would appreciate any tips.
Here's a copy of that sample data from above in a Google Sheet.:
https://docs.google.com/spreadsheets/d/1J384S0fsc8tgxVMehPb_uyRNc5-6cQx-xKN-q8K8Gds/edit?usp=sharing
I created a new sheet and entered in cell A1
=ArrayFormula(iferror(vlookup(unique(Sheet1!A2:A), sort(Sheet1!A2:E, 3, 0), {1, 2, 3, 5}, 0)))
See if that works for you ?
BREAKDOWN:
The general idea behind the formula is to make use of the fact that VLOOKUP only returns the first match. We want that 'first match' to be the latest date per book.
So first we sort the table so that the latest dates are on top.
We 'lookup' the unique book titles in that sorted table and we return the columns {1, 2, 3, 5}.
Links:
sort() function
vlookup() function

Google Spreadsheets - Join or Concatenate text from multiple rows that have matching values in one of the columns

As the title says, I need to join or concatenate text from multiple rows that have matching values in one of the columns. (Using latest Firefox, Widows 7).
In Sheet1 I have a table that looks like this (sorry if it looks messy - I don't know how to do a neat table on SO):
David | 1 | Blue
Steve | 1 | Green
James | 2 |
Chris | 1 |
Steve | 3 | Blue
Jack | 1 |
Ben | 1 |
James | 1 |
Jack | 2 | Yellow
George | 4 |
In Sheet2, I would like a table that looks like this:
David |1| Blue
Steve |4| Green & Blue
James |3|
Chris |1|
Jack |3| Yellow
Ben |1|
George |4|
Column A show unique values (names) and column B shows the sum for that name.
I have successfully generated columns A and B but I'm having difficulty generating the third column which should return 'Green & Blue' for Steve and 'Yellow' for Jack etc.
Does anyone know how to do this? Your help would be much appreciated.
I have generated Sheet2 columns A and B with the follwing formulas:
Column A: =UNIQUE(Sheet1!A:A)
Column B: =SUMIF(Sheet1!A:A,A1,Sheet1!B:B).
Here is the spreadsheet: https://docs.google.com/spreadsheet/ccc?key=0Avg34WusBUlRdGY1X3BSRlYxaWVkSmo3eVQzYlNvMXc
Thanks for looking.
Use the JOIN function combined with the FILTER function
So in Column C:
=JOIN(" & ",filter(Sheet1!C:C,Sheet1!A:A=A1))
Hope it helps.

Resources