I'm trying to put together an investment tracking sheet. For the overview page, I want to query and combine data from each of the account tabs but I'm having difficulty figuring out how to make that work.
Here's a link to my test sheet: https://docs.google.com/spreadsheets/d/14sZmxkM65ax9BKrkjinwOrOQPrS_xhqPPLs68Rggii4/edit
The formula I tried to use is in column J on the Overview tab. This formula works in Excel, but not Google Sheets:
=IF(F2<>"",SUMPRODUCT(SUMIF(INDIRECT("'"&Accounts&"'!"&"$N$2:$N$1000"),F2,INDIRECT("'"&Accounts&"'!"&"$O$2:$O$1000"))),"")
Accounts is a named range with the 4 account tab names
Column N on each account tab has the stock name
Column O on each account tab has the share count
Column F on the Overview tab has the stock names to match
If I run the same spreadsheet in Excel, the above formula works correctly and the share counts are correctly added from the 4 accounts: 120/20/50/101.
In google sheets I understand that INDIRECT doesn't support arrays, so it only shows the share counts from the first account: 100/20/0/0
So my question is if anyone can tell me how to modify the formulas from column J to work in Google Sheets?
Thank you.
delete your whole column J and use this:
=ARRAYFORMULA(IFNA(VLOOKUP(F2:F, QUERY(
{Account1!N:O; Account2!N:O; Account3!N:O; Account4!N:O},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1"), 2, 0)))
Related
I'm creating a Budget calculator spreadsheet in Google Drive, I'm trying to update cells from another Sheet with certain criteria:
This is Sheet1:
According to the date and category should update a cell from another Sheet in the same document, with the quantity.
This is Sheet2:
I'm not sure If I'm able to implement this flow in the same Google spreadsheets or if I should use Python instead. I tried everything and I'm stuck here. If someone could give me a hint about it I'll appreciate it a lot.
Here's the link to the spreadsheet: https://docs.google.com/spreadsheets/d/1BEtKJGVOdVF8PLxcR_96cPjE_4XH0QFbtV9dynroly0/edit?usp=sharing
try this cobra query in B13:
=INDEX(IFNA(VLOOKUP(A13:A21, QUERY({Sheet2!A3:D;
TO_DATE(SEQUENCE(12, 1, 2, 33)), 0/SEQUENCE(12, 3,,)},
"select Col2,sum(Col4)
where Col2 is not null
group by Col2
pivot month(Col1)-1"), SEQUENCE(1, 12, 2), )))
I've 3 or more Google sheets. Each sheet covers different aspects of employee info. These sheets would get new entries added every now and then. All the sheets have ID column.
The new sheet has UNION of all fields from different sheets joined by a common field present in every sheet, e.g. email id.
For example:
Source 1:
Source 2:
Expected new sheet with the integrated data joined by email id is:
Ideally, the integrated sheet should not have the repetition of join key, i.e. Email.
I want this integrated sheet to be automatically updated with new rows as and when new data comes in all the sheets. Ideally, this should happen when data in all the source sheets are complete for a given ID.
What is the best way to achieve this?
use arrays {} like:
=UNIQUE(QUERY({Sheet1!A2:B; Sheet2!A2:B; Sheet3!A2:B};
"where Col1 is not null"))
update 1:
=UNIQUE(QUERY({
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet1!A2:B");
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet2!A2:B");
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet3!A2:B")};
"where Col1 is not null"))
side note: each importrange formula needs to be run as standalone to connect your sheets by allowing access - only then you can use above formula
update 2:
if columns are mixed you can "correct" them like:
=UNIQUE(QUERY({
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet1!A2:C"); "select Col1,Col2,Col3");
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet2!A2:C"); "select Col3,Col2,Col1");
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet3!A2:C"); "select Col2,Col3,Col1")};
"where Col1 is not null"))
I'll start off by saying that I'm not very familiar w/ google sheets and its formulas.
How would I go about solving this?
I have two columns: A and B. I want to count the cells under column B under these conditions:
look at rows under column B where its corresponding values in column A are not duplicates.
Would this require multiple steps?
try:
=COUNTA(IFNA(FILTER(B1:B, REGEXMATCH(B1:B&"",
TEXTJOIN("|", 1, FILTER(A1:A, COUNTIF(A1:A, A1:A)=1))))))
I have a Google Sheet (Test Sheet 2) with two sheets in it, Sheet 1 and Sheet 2. Sheet 2 is where all of the data is and I need to get the sums of the counts of that column based on three criteria into sheet 1 column C. The name, week, year and count need to match up. I used the formula
=arrayformula(iferror(vlookup(A2:A&2020&B2:B, {Sheet2!A2:A&Sheet2!B2:B&Sheet2!C2:C, Sheet2!D2:D}, 2, FALSE)))
but that only works for unique rows. In the example sheet I am providing, the formula works well for Bill, Lisa, Katie and Jon because they all have one value for 'count' from Sheet2 when the parameters of name, week and year match up. But Mike has two rows matching the criteria. This formula returns the first match which is 3. The other value is 4 so I would like the count in Sheet1 to show 7 instead of 3. I need it to add them up.
I also tried to use sumifs but the columns are two different sizes so that didn't work.
Any idea? I did try to combine sumif with the above formula but that did not work either.
Link to Test Sheet
Solution with ARRAYFORMULA and SUMIF
If you need to use ARRAYFORMULA to improve the performances you can use this tweak of the SUMIF statement: basically you can concatenate the conditions to make them create a single AND condition.
This would be a possible solution for the formula in your comment:
=ARRAYFORMULA(SUMIF(Sheet2!A2:A&Sheet2!B2:B,A2:A&2020,Sheet2!D2:D))
Solution with SUMIFS
If you are looking for a solution with the SUMIFS formula you can use this:
SUMIFS('sum_range', 'criteria_range', condition, ['criteria_range_2', condition_2])
In your case this will translate to:
=SUMIFS(Sheet2!D2:D, Sheet2!A2:A, A2, Sheet2!B2:B, 2020)
In this case the ranges dimensions won't affect the formula execution.
Just drag this formula for the Sheet1 table column and you will get the results. The drawback is that you cannot use ARRAYFORMULA with SUMIFS. Performance wise, if you have a lot of rows in the Sheet1 I suggest using the ARRAYFORMULA solution, since this will trigger a lot of formula calls instead of just one.
Try this query()
=query(Sheet2!A:D, "Select A, C, sum(D) where B = 2020 group by A, C label C 'Week', sum(D) 'Count'", 1)
UPDATED:
If you really need to use vlookup in arrayformula() you can always ise the query (that deals with the summing) as the lookup range. In the spreadsheet I used
=ArrayFormula(if(len(A2:A), iferror(vlookup(A2:A&year(D2:D)&E2:E, query({Sheet2!A:A&Sheet2!B:B&Sheet2!C:C, Sheet2!D:D}, "Select Col1, sum(Col2) where Col1 <>'' group by Col1", 1), 2, 0)),) )
and see if that helps?
I have a spreadsheet with 2 sheets in it, I want to summarize the weekly results by date. I'm trying to use the query sum function to summarize everything since I wasn't able to do it with arrayformula.
but I'm not able to do it with a query as well. I don't want to just copy-paste the sum function from each row to the next I want to just type the date I need in column A and get all the results in the different columns.
https://docs.google.com/spreadsheets/d/1ZsKXw32ycO_5KGD2I-Ug_GmqSIB_Z-D3Z1jlGd6fpTE/edit?usp=sharing
link to sheets.
getting the data from the database sheet. I want to display the data-oriented by date and summed.
=ArrayFormula(IFERROR(FILTER(QUERY(DataBase!A2:E,"select A,sum(E)
where A is not null
group by A
label sum(E)''"), WEEKNUM(DataBase!A2:A)=WEEKNUM(A2:A))
))
I tried this formula and it dosent work..
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,
QUERY(FILTER(DataBase!A2:E,WEEKNUM(DataBase!A2:A)=WEEKNUM(A2)),
"select Col1,sum(Col5)
where Col1 is not null
group by Col1
label sum(Col5)''"), 2, 0)))