I am having the following problem: There are two Sheets in my document which contain different data about the cities (which are listed in column A in both cases). I am trying to create a combination where the data about a given city is merged from the second sheet.
I was trying to explore QUERY function, as it's suggested in a similar topic:
=QUERY({Sheet1!A2:C5;Sheet2!A2:C5},"select Col1 where Col1 <>''") However it's not clear how to replace the where Col1 <>'' with an appropriate statement.
Since Query Docs does not support Join similar to SQL, one workaround is to use ARRAYFORMULA, VLOOKUP, and indirect reference to achieve a similar result:
=ARRAYFORMULA({Sheet1!A1:C5,VLOOKUP(Sheet1!A1:A5,Sheet2!A1:B5,COLUMN(INDIRECT("R1C2:R1C"&COLUMNS(Sheet2!A1:B5),0)),0)})
From your tables on the question, the result looks like this:
References:
ARRAYFORMULA()
VLOOKUP()
INDIRECT()
COLUMN()
COLUMNS()
Related
I was trying use query to show results as below. But I couldn't figure out how to use Column A (months) as a header.
I knew how to use Vlook or Filter function to generate same results. Since my data is huge, I prefer to use Query function to keep my data flexible. Thank you for helping.
https://docs.google.com/spreadsheets/d/1ljrMdM4m0YT35EP7HxY-Gdj9SrEv6DHoQw_qL8Z9c-Y/edit?usp=sharing
Something like this should work, needs tweaking with ordering though.
=query(Sheet1!A1:C71,"select B, sum(C) group by B pivot A")
I am making a spreadsheet to compare various lists in various different ways. One of those ways is to take a bunch of separate lists (each in different columns) and combine them into one large column (without losing anything). This allows me to keep things separate while still having the option to VLOOKUP and FILTER and stuff. Maybe this isn't the way to go about it, but it's the way I've gone with so far.
The solution I came up with for now is to QUERY it all as an array (I think that's the right term) and then just select everything that isn't "".
It looks like this though:
=QUERY({Decklists!B8:B;Decklists!C8:C;Decklists!D8:D;Decklists!E8:E;Decklists!F8:F;Decklists!G8:G;Decklists!H8:H;Decklists!I8:I;Decklists!J8:J;Decklists!K8:K;Decklists!L8:L;Decklists!M8:M;Decklists!N8:N;Decklists!O8:O;Decklists!P8:P;Decklists!Q8:Q;Decklists!R8:R;Decklists!S8:S;Decklists!T8:T;Decklists!U8:U;Decklists!V8:V;Decklists!W8:W;Decklists!X8:X;Decklists!Y8:Y;Decklists!Z8:Z;Decklists!AA8:AA;Decklists!AB8:AB;Decklists!AC8:AC;Decklists!AD8:AD}, "select Col1 where Col1 <>''", 0)
Which is really ugly. It works and does what I want, but I'd much prefer it to be clean and work if I add more columns in the future, without having to go and add the additional "call".
If you'd like to look at the whole sheet, it's here: https://docs.google.com/spreadsheets/d/17Nwek5ZCgu7Jvk922hl_gv9UJAeORjeH9brXqu3zL_Y/edit#gid=940775206
On the "Best Buys" sheet cell C2 Paste this simple formula.
=QUERY(FLATTEN(Decklists!B8:AF), "select Col1 where Col1 <>''")
Explanation
1 - FLATTEN the range needed in this case the Decklists range Decklists!B8:AF.
2 - QUERY the resulted column from the FLATTEN function with the query "select Col1 where Col1 <>''", to get only non empty cells
Try
=query( flatten(offset(Decklists!A:A,0,1,,columns(Decklists!1:1)-1)) ,"where Col1 is not null",0)
So we have 3 things to do, first one is transpose so the columns are below the other, then flatten so that it is ordered as necessary and finally a filter to remove extra blank columns we selected This will work wonders considering the columns are different lengths, are already next to each other as in a table. If columns are at multiple places use {A:A;D:D} to select columns and remove flatten and transpose.
=filter(flatten(transpose(A1:D10)), len(flatten(transpose(A1:D10))))
I have a google sheet that is looking at another sheet in the same workbook with cell values that are a string list populated by a pandas dataframe generated from a REST API json response.
I need to visualize this data so I'm thinking need to parse the comma separated values from the list, then append/stack them on top of one another so that I can reference the column in a pie chart in Google Data Studio.
I parsed the values using the SPLIT function (column C) but now stuck on how to append them into one column stacked on top of each other.
There could also be a totally different approach here that I'm not thinking of. Any tips on how to build this out so it's in an array method (updates as the reference sheet is updated daily) that would be awesome - thanks all.
Alternatively if there's a way to create a field at the Google Data Studio report level that would work well too.
use:
=ARRAYFORMULA(QUERY(FLATTEN(IFERROR(SPLIT(REGEXREPLACE(Sheet2!A2:A,
"\[""|""\]|"",""|\['|'\]|','", "♦"), "♦"))),
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''"))
I am stuck with a task which am seeking help from you guys. the solution I want is to find common words in two columns. eg if a word comes common in two cells it must appear in another column. we don't need the words only in one column.
https://docs.google.com/spreadsheets/d/1u_AD1FAbq0ntushGSYZBsR59iPX1_p5ZSIq1mowQSQ4/edit#gid=0
pls take a look to the shared link.
A screenshot also is shown here:
In a array context,
MATCH Col1 against Col2 getting indexes of strings in Col1 that are present in Col2
FILTER Col1 against the resulting matched array
=ARRAYFORMULA(FILTER(A2:A10,MATCH(A2:A10,B2:B10,0)))
In Google Sheets, I'm trying to use AVERAGEIF to calculate an average of only some of the columns in another table.
The columns to be included in the average are marked by some text in a specific cell (e.g. the first or last row of that column).
Some columns are to be included in several averages, so the text in the top\bottom row would include several words (effectively meaning I'll need some sort of substring check such as FIND).
I've tried using AVERAGEIF() in conjuction with FIND() but couldn't get this to work.
Any ideas?
Here is an example of how the data sheet looks like, and how I would expect it to work
You can use following formula:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(D2,A2:A9)),B2:B9,"")))
Edit:
For table mentioned in comment you must change ranges:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(E2,$A$1:$C$1)),$A$2:$C$4,"")))
You can use a query
=AVERAGE(QUERY(TRANSPOSE($A$1:$D),"where Col1 contains '"&D1&"'"))
Functions used:
AVERAGE
QUERY
TRANSPOSE