show all results on VLOOKUP - google-sheets

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"'"))

Related

Know first match of COUNTIFS in 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"))

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))), " ")))

Is it possible to aggregate expenses per category in google spreadsheets

I am trying to track my expenses manually. I looked for already built options and I did not find anyone I knew how to use or that it covered what I want to do.
What I am doing is basically manually write down what appears in my bank, with the intention of categorizing the expenses myself, since as I said, I did not find a better way to do it.
So it looks like this:
Cinema | 11.95
Going out (restaurant1) | 26.55
Netflix | 13.95
Weekly purchases | 72.66
Going out | 9
Bill (type) | 29.16
Rent month | 650
Going out | 26.55
Bill (type2) | 66.45
Compra semanal | 81.09
Bill (type3) | 21.1
( "|" is used as if it were two different cells) And what I would like now is to take the generic name that I gave the cathegory (without the parenthesis, I am using those for myself, so I can track where was the money spent, more specifically), and how much was spent.
In programming I would do this with a regex for the left cell, and aggregating by name, and then plotting the data somehow. I am unsure if this is even possible, maybe I should use Excel but Drive has the cloud advantage so I would like some help as to where to start, I do not need anything too fancy, a new column with the category and the total spent would work wonders for me, but I have not found an easy way of doing it (and I doubt I am doing something so complex, so I assume I am thinking this the wrong way). Best case scenario, I manage to plot it all so it is more visual, or I can have several columns plotted against each other (I have different columns for shared expenses, personal expenses, and so on).
If you can put the category (e.g. Bill) in a separate column from your details (e.g. type 1) then the Pivot Table feature is exactly what you need.
Start with something like this (the heading on each column is important):
Category | Details | Amount
Cinema | | 11.95
Going out | restaurant 1 | 26.55
Netflix | | 13.95
Weekly purchases | | 72.66
Going out | | 9
Bill | type | 29.16
Rent month | | 650
Going out | | 26.55
Bill | type2 | 66.45
Compra semanal | | 81.09
Bill | type3 | 21.1
Then click Data, Pivot Table. Under Rows, click Add and choose Category. Under Values, click Add and choose Amount. You should see a table like this:
Category | SUM of Amount
Bill| 116.71
Cinema | 11.95
Compra semanal | 81.09
Going out | 62.1
Netflix | 13.95
Rent month | 650
Weekly purchases | 72.66
Grand Total | 1008.46
Any unique value in the Category column creates a new row in the pivot table.
Further Details: https://support.google.com/docs/answer/1272900
=ARRAYFORMULA(QUERY({REGEXREPLACE(TRIM(A:A)," \(.*\)",),B:B},"Select Col1,sum(Col2) where Col1 is not null group by Col1"))

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