A formula that returns data from a range of two or more columns in one column - google-sheets

result
1
a
1
2
b
2
3
c
3
4
d
4
5
e
5
6
6
7
7
a
b
c
d
e
I want to list all the data in the range A:B as a return value in column C where the formula is written. Empty cells should be ignored.
I've tried getting a specific range of data with the indierct or indexof functions, but I have no idea how to concatenate them into one column in order if the target is more than one column!

You can try:
=LAMBDA(z,FILTER(z,z<>""))(FLATTEN(A:A,B:B))
Incase the new functions have rolled out for you, try:
=TOCOL(A:B,1,1)

Related

Google Sheets: Query and list the last 5 values in a column if the column contains a number

I want to use Sparkline for a spreadsheet to show a trend of the last 5 soccer matches, where A and B are the goals, and C are the resulting points.
In column C, the points are only generated if values are entered for the goals and goals conceded, i.e. the columns are not empty.
A (Goals)
B (Conceded)
C (Points)
4
4
1
4
4
1
4
4
0
3
4
4
1
0
4
0
As you see, in row 3, column c is empty.
What I basically try to achieve, is to create a list where the last 5 entries which are not empty / null, are listed:
C (Points)
1
1
3
1
0
Is used this formula, but it somehow does not work
=query(J15:J114,"select * offset "&count(J15:J114)-5)
shorturl.at/gHPY9 (example result picture)
Tried to find a solution myself, but am stuck.
Best,
Feal
Use query() with a where clause, like this:
=query(
J15:J114,
"where J is not null
offset " & max(0, count(J15:J114) - 5),
0
)

Count number of rows for each type in google spreadsheet

A B C
1 4 Apple
2 5 Orange
3 6 Apple
1 4 Orange
2 4 Apple
3 4 Banana
I want to count each type of column C(if possible also plot it), ie output should be
Apple 3
Orange 2
Banana 1
Just more to a new columns and paste the folloing in its header:
=query(H2:H,"select H, count(H) where H != '' group by H order by count(H) desc label H 'Fruit'", 0)
It is show something like your expection in new two columns beside the original data
As an alternative to the solution already provided, you can make use of UNIQUE and COUNTIF.
Use UNIQUE in order to extract the names for each fruit from the C column
=UNIQUE(C1:C)
Use COUNTIF within an ARRAYFORMULA in order to count the number of times each fruit is present in the C column and later drag it down the E column:
=ARRAYFORMULA(COUNTIF(C1:C,D1))
Reference
UNIQUE Function;
COUNTIF Function.

Sheets: Count Row data Based on Key

Im trying to find a Row based on a value, and count the number of entries (Max 5) in that row.
A
B
C
D
E
F
G
1
John
2
2
5
4
2
Mary
1
3
1
6
7
=COUNTA(B1:GZ) will work if I knew the row for "John",
but im trying to get the row based on a value from another cell ...
Z
10
John
In this case Z10 pseudo: =COUNTA(Find Z10 in Col A, then count entries in Row starting at B to Z)
Any ideas ? Thanks.
Recommendation:
You can try this method
=COUNTA(QUERY(A1:Z, "Select * where A = '"&Z10&"'"))-1
Sample
Sample sheet:
John added on cell Z10
The recommended function added on cell Z11
Result: 4 was the result of COUNTA on the rows B:Z based on Column A that contains the value "John"
NOTE:
You may need to turn on Iterative calculation on your Spreadsheet settings.

Search with query formula where cells are not nothing

I have range of cells and want to search with query formula where cells are not nothing.
A B C D
1 a 11 44 qw
2 b 12 r
3 c 13 44 444
4 NOT
5 f 15 55 88
6 NOT
7 h 17 gh ee
Cells in C maybe any number, maybe any word, maybe any nothing.
I want to select everything A where C has nothing.
Result must be:
a
b
c
f
h
When try all the querys formula:
=QUERY(A1:D7,"select A where not C<>'' ")
=QUERY(A1:D7,"select A where not C!='' ")
=QUERY(A1:D7,"select A where not C is null")
=QUERY(A1:D7,"select A where C !='' or not C is null")
Nothing give correct result. Looked everywhere.
What can I do?
Google QUERY function does not work here as "expected" because of mixed data types in column C. If we apply the formula =QUERY(A1:C7;"select A where C is not null";-1)
it will return only "a, c and f". The image below shows this result in column G, where G1 contains the above formula.
We should check data types more carefully, but it is difficult to do inside QUERY function. So I suggest to add one more column (E in our case) and fill it with "=TYPE(C1)" and similar functions. Having data types column, we can modify QUERY expression to take them into account. Final result is shown in column H.
Please check this approach again, if you are going to use other data types in column C.
=QUERY(A1:D7, "select A where C is not null")
...is what you need

vlookup return array (formula only, no code please)

I have a table like so:
A B C D
1 3 2 1
2 3 2 1
3 0 2 2
I want to vlookup the first column so that it returns the 3 columns after.
For example if I look up 2, i want the return to be 3 2 1.
i need it in one formula because it will go into a sumproduct expression.
Does not have to be a vlookup. I just need something that will return me an array though some type of indexing or lookup.
One of the ways to achieve this is query. So for the data given by you (A, B, C are column), you can use the following formula to get all three columns for the lookup value 2
=QUERY($A$1:$D$3,"select B,C,D where A = 2")
Then you can apply any aggregate function on top of this too. For eg:
=sum(QUERY($A$1:$D$3,"select B,C,D where A = 1"))
Check this link

Resources