I have to work with a large table on Google Sheet containing, roughly, weights associated with a day (and other superfluous data).
It looks like this:
Date
Weight 1
Weight 2
Weight 3
01/01/22
20
22
21
01/02/22
19
25
A date, and multiple weights associated.
Ideally, I would need an intermediate table that includes all the columns of the initial table, but with one weight per row.
Like this one for example:
Date
Weight
01/01/22
20
01/01/22
22
01/01/22
21
01/02/22
19
01/02/22
25
I tried several methods to filter this table and retrieve all the weights for each date independently.
Index/match, filter, query...
I couldn't get what I needed.
Do you know if there is a formula that would allow me to obtain this second table?
try:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(if(len(B2:D)*len(A2:A),A2:A22&"|"&B2:D22,)),"|"),"Select * Where Col2 is not null"))
try:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(A2:A&""&B2:D), ""), "where Col2 is not null", ))
Related
I have one workbook that has daily tracking of bidding dates and amounts and win day and amounts. In another workbook, I access that information to see the totals per day. Then play with that to see week/month/quarter and year performance. The problem I have is that I can not get my query searches to work in an array manner and have to drag the date driven formulas down 364 times for each column of information and all it's done is create a slow database...
=QUERY(importrange('source addresses'!$B$2,"bid tracker!$a$3:$x"),
"SELECT SUM (Col9)
WHERE Col8 = date '"&text(B5,"yyyy-mm-dd")&"'
label sum(Col9) '' ",0)
Col9 = amount of contract
Col8 = date of win
This formula produces a single data output for the sum of that days wins, I need it to array all 365 days to eliminate the other 364 of THESE formulas I am using due to my inexperience.
I have used arrayformula before query and after and every example I see doesn't seem to apply or work for me...
You need group by clause like group by Col8. Try-
=QUERY(importrange('source addresses'!$B$2,"bid tracker!$a$3:$x"),
"SELECT SUM (Col9)
WHERE Col8 <= date '"&text(B5,"yyyy-mm-dd")&"' AND Col8 >= date '"&text(B5-369,"yyyy-mm-dd")&
"' group by Col8 label sum(Col9) '' ",0)
I have a problem with summing up my values from a data set, that's structured like this:
The goal is to sum the revenues separated by company and split by month, so the result is output in this way
I have tried it with some =sumifs + index/match and =sumproduct solutions, but can't seem to make it work.
Here's the sample file:
https://docs.google.com/spreadsheets/d/16xOoPCHDtcSRRojCkwcBorUc5dstgkXFPR6M_d5uY2U/edit#gid=0
On the "revenues" tab, in cell B4, try using the formula:
=SUMIFS(indirect(address(1,match(A4,Overview!$3:$3,0)-1,,,"Overview")&":"&address(1000,match(A4,Overview!$3:$3,0)-1)),Overview!A1:A1000,">="&B$2,Overview!A1:A1000,"<="&B$3)
To break it down, this bit helps figure out which revenue column to use by matching the name of the company and then taking the column before that:
match(A4,Overview!$3:$3,0)-1
This bit creates an address "Overview!$G$1":
address(1,match(A4,Overview!$3:$3,0)-1,,,"Overview")
This bit creates the 2nd part of the address i.e.":$G$1000":
"&":"&address(1000,match(A4,Overview!$3:$3,0)-1)
And the rest is a SUMIFS where it sums the revenue column for dates after the 1st of the month and before the last date of the month.
Be careful: your data is for 2020 and your summary table is using dates in 2021.
Reference:
SUMIFS
ADDRESS
MATCH
INDIRECT
use in A4:
=ARRAYFORMULA(QUERY(QUERY({SPLIT(FLATTEN(IF(
FILTER(Overview!G7:1000, MOD(COLUMN(Overview!G7:1000)+2, 3)=0)="",,
TEXT(Overview!A7:A25, "m")&"×"&
FILTER(Overview!G7:1000, MOD(COLUMN(Overview!G7:1000)+2, 3)=0)&"×"&
FILTER(Overview!G3:3, MOD(COLUMN(Overview!G3:3)+1, 3)=0))), "×");
SEQUENCE(12), SEQUENCE(12, 2,,)},
"select Col3,sum(Col2)
where Col1 is not null
group by Col3
pivot Col1", 0),
"offset 2", 0))
I have 2 columns of data in a Google Sheet. Column1 is unique words or sentences (words are repeated in sentences) and the Column2 is a numeric value next to each (say votes). I am trying to get a list of unique words from Column1 and then the sum of values (votes) from Column2 when the word was present either on its own or in a sentence.
Here is a sample of the data I am working with in Google Sheets:
Term Votes
apple 20
apple eat 100
orange 30
orange rules 40
rule why 50
This is what the end result looks like:
Word Votes
apple 120
eat 100
orange 70
rules 40
rule 50
why 50
The way I am doing it now is quite long and I am not sure if this is the best solution.
Here's my solution:
JOIN values in Column1 using a delimiter " " and then SPLIT them using the same delimiter and then TRANSPOSE them into a column all in one step. This way I have a list of all the words used in Column1 in say Column3.
In Column4 pull out all the UNIQUE values and then do a COUNTIF for the unique values from Column3. This way I am able to get the frequency of each unique word by referencing to the lsit of all words.
In order to get the sum of Votes I have to TRANSPOSE Column4 and then QUERY Column1 and Column2 by using dynamic text in the formula. The formula looks like =QUERY(Column1:Column2, "SELECT SUM(Column2) WHERE Column1 CONTAINS '" & referenceToUniqueWord & "'", 1). The reason I have to transpose first is because the query formula outputs 2 cells of data ie Text: sumColumn1 and Number: 'sum of votes'. Since for one cell of unique word I get two cells of data I am not able to drag the formula down and hence I have to do it horizontally.
I finally get three rows of data after the last step:
One row is just transposed Column4 (all the unique words). Second row is just the text sumColumn2 from using the QUERY formula. And third row is the actual sum of votes, resulting from individual QUERY formulae. I then transpose these rows to columns and to get my final table I VLOOKUP the frequency values arrived at earlier.
This approach is lengthy and prone to errors. Also doesn't work if the list is large and in the initial JOIN I get an error of limit 50,000 reached. Any ideas to make it better are welcome. I know this can be done much easier using Scripts but I'd prefer to have it done using only formulae.
try:
=ARRAYFORMULA(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(
IF(IFERROR(SPLIT(A:A, " "))="",,"♠"&SPLIT(A:A, " ")&"♦"&B:B)
,,999^99)),,999^99), "♠")), "♦"),
"select Col1,sum(Col2)
group by Col1
order by sum(Col2) desc
label sum(Col2)''"))
Let's say I have the following spreadsheet:
https://docs.google.com/spreadsheets/d/1FY7GnhZoT2_Tzm8FLOkDuc5XR8TkFhBJKgW_qZ1r4Cc/edit?usp=sharing
On the top left column, I have a formula that counts the events and sorts them according to the frequency. Anyway, what I want to do now is instead of just counting the frequencies of the actions, I want to count the number of unique actions. For example, in my spreadsheet, the action call came up 5 times: 2 times by Joe, 2 times by Mary, 1 times without a user (empty). Therefore, next to the call action on my left-hand table, I would want 2 because the number of unique pairs (event and user) is exactly 2.
So using the above logic, what I want my left side table to be is the following:
Call 2
SMS 1
Review 1
Hopefully, I have made myself clear.
How can I do this using my example spreadsheet? Thanks.
try:
=ARRAYFORMULA(QUERY(UNIQUE({D:D, D:D&E:E, E:E}),
"select Col1,count(Col1)
where Col3 != ''
group by Col1
order by count(Col1) desc
label count(Col1)'Count'", 1))
I have try to get sum of two columns using query function in Google Sheets.
Col1 Col2 Col3
-----------------------
12 User1
23 44 creature
55 User1
14 User1
This work fine if there are at least one number in each column:
=QUERY(IMPORTRANGE('SomeURL';"Page!A1:C");
"select (sum(Col1) + sum(Col2)) where Col3 = 'User1'")
However this query cause error QUERY:AVG_SUM_ONLY_NUMERIC if all cells in one column are empty in result set.
Col1 Col2 Col3
-----------------------
12 User1
23 44 creature
User1
14 User1
How can I get sum of columns using query function, if sometimes the cells are empty in one of the column?
=ARRAYFORMULA(SUM(query(IMPORTRANGE("url","page!A1:C6"),"select Col1,Col2 where Col3 = 'User1'")))
This should work for a simple sum. But i don't think there's a way inside QUERY to consider blanks as zero or assume them as numbers. If you could actually import range into sheet(i.e., use them as helper columns), then you can use ARRAYFORMULA(Query ({filter (A1:B6*1,NOT(ISEMAIL(A1:A6))),C1:C6}, "select *.... You should convert blanks outside Query (by *1)or Sum them outside query. Or use a DOUBLE Query and double import range, which would be performance depreciative.
You can SUM the Query, like this:
=sum(query('SomeURL';"Page!A1:C"); "select Col1, Col2 where Col3 ='User1'"))
OR use SUMIF() twice, once for each column. It means 2 importranges, though, so it will probably be slower.