I have a Google Sheets Document with 2 Sheets, Inventory and Pending Transactions.
My goal is to create a new sheet with Available items.
Company,Item,Quantity
Walmart,ToyA,100
Walmart,ToyB,5
Amazon,ToyA,2000
Amazon,ToyB,100
Amazon,ToyC,5
----
Company,Item,Pending
Walmart,ToyA,2
Walmart,ToyB,4
Amazon,ToyA,1990
My idea is to Join the Items together.
Company,Item,Inventory,Pending,Available
Walmart,ToyA,100,2,{Computed}
Walmart,ToyB,5,2,{Computed}
Amazon,ToyA,2000,1990,{Computed} # All of the {Computed is Inventory minus Pending}
Amazon,ToyB,100,2,{Computed}
Amazon,ToyC,5,2,{Computed}
My Original idea was to Show the items merged on a Primary key of Company:Item, but i have no problem creating a new sheet which handles all of this. I was trying to do things like: =Query({Sheet1!A:D;Sheet2!A:D}, "select *") but that appends Sheet2 to the End of Sheet1, which is not what I wanted.
I got stumped, and after looking at a bunch of different Questions I couldnt find the example I was looking at.
To merge the items without blank rows, use
={QUERY(Sheet1!A2:D, "SELECT * where not A like '' ");
QUERY(Sheet2!A2:D, "SELECT * where not A like '' ")}
if you want to know from which sheet the data are coming, use
=QUERY({
ARRAYFORMULA({IF(ISBLANK(Sheet1!A2:A),,"#1") ,Sheet1!A2:D});
ARRAYFORMULA({IF(ISBLANK(Sheet2!A2:A),,"#2") ,Sheet2!A2:D})
},"select * where Col1 <> '' ")
Related
I have a list of email addresses in one sheet (first column).
I have a list of transactions in another sheet with emails and sale amounts.
I am looking for a formula that adds up all the transaction $ sales for any transactions made by the people (emails) in the first sheet.
Any help would be much appreciated!
Your sample data is very limited (only one row matching one person, in fact). But the following formula should work for you. Place it in a new sheet, in cell A1:
=ArrayFormula(IFERROR({"Name","Total"; QUERY(FILTER(Transactions!A2:D,NOT(ISERROR(VLOOKUP(Transactions!A2:A,Tags!A:A,1,FALSE)))),"Select Col2, SUM(Col4) GROUP BY Col2 ORDER BY Col2 LABEL SUM(Col4) '' ")},"No Data"))
This one formula will produce the headers (which you can change within the formula itself as desired) and all results.
FILTER filters in only 'Transactions' data (names through amounts) where the emails are found in the 'Tags' sheet.
Then QUERY returns the name and totals for each match in alphabetical order by name.
If there are no matches, "No Data" will show instead.
If I understood your question correctly!
Try this on the sheet, where you only have emails and wanted to get sum of sales amount
=sumifs(range_whichHasTransaction , range_of_Email_inThat_TransactionsTable , Cell_Reference_ofEmail_forWhich_you_want_sum_the_Transaction_Amount)
it will Look something like this:-
sumifs(TransactionSheet!B:B,TransactionSheet!A:A,Emails!A2)
Reference
SUMIFS
I use this Query formula in Google Spreadsheet to merge tables from many source sheets into one table:
=query({Data1!A4:B;Data2!A4:B;Data3!A4:B}; "select * where Col1 is not null")
To distinguish original tables in the merged table, I need to add new column to the merged table with their identification. The indentification string is in cells on every source sheet. How to do it?
This is example spreadsheet I prepared for tests. Copy it to your Google Drive to make changes please.
https://docs.google.com/spreadsheets/d/1YimEsiDa3gTiKqv7DMohfNvBDruvQ13zrK23Y3R3Gsw/edit?usp=sharing
I suspect the simplest way is the "long-winded" add a column in each sheet (say a new "A") and populate that with the sheet name, so then a query like so:
=query({Data1!A4:C;Data2!A4:C;Data3!A4:C}; "select * where Col2 is not null")
Edit re Comment:
Not the layout required but at least differentiates the source without adding anything to the sources:
={query(Data1!A4:B,"select * where A is not NULL label A '"&Data1!B1&"'");query(Data2!A4:B,"select * where A is not NULL label A '"&Data2!B1&"'");query(Data3!A4:B,"where A is not NULL label A '"&Data3!B1&"'")}
I'm trying to merge multiple tabs into one master sheet. This is working fine:
=QUERY({SheetOne!A16:B;SheetTwo!A16:B;SheetThree!A16:B;SheetFour!A16:B}, "SELECT * WHERE Col1 IS NOT NULL", 0)
And it gives me the table
Week,Users
12,123
13,234
14,345
12,123
13,234
14,345
12,123
13,234
14,345
However, I'd like another column that creates a reference to the sheet. So the result I'd like is:
SheetName, Week, Users
SheetOne,12,123
SheetOne,13,234
SheetOne,14,345
SheetTwo,12,123
SheetTwo,13,234
SheetTwo,14,345
SheetThree,12,123
SheetThree,13,234
SheetThree,14,345
Thanks. Bonus question: How to insert a custom string-value instead of SheetOne,SheetTwo [...]
I am trying to do some data reduction in my Google Sheets by using the following IMPORTRANGE formula:
=query(importrange("https://docs.google.com/a/ap.averydennison.com/spreadsheets/d/1xz1lXY-w5Ii_aWqVAhHgRCmeoes9ltSUtibE4kzhMHA/edit#gid=2051232966","SF_Flex_Rel!a:l"),
"select * where Col1 = '"&text(B1,"###")&"'",1)
The 'source' sheet has a whole lot of sales data records. What I am trying to do in the new sheet via this formula is only bring in the sales records from the source sheet that match the customer number specified in cell B1.
It seems to work OK if I limit the IMPORTRANGE to only query about 10,000 rows. Once I go over around 20,000 rows the screen will briefly flash up the records, then a small progress bar shows in the top right corner of the sheet and the records disappear. The cell with the formula just shows #ERROR! with no other comments to tell me why.
Is there something wrong with my formula syntax?
Is there a better way to achieve this data reduction?
Is there some undocumented data limitation on IMPORTRANGE function (I am using 'new' Google Sheets)?
try like my example :
=QUERY( // data
IMPORTRANGE(
"Spreadsheet Key", // spreadsheet key
"DATA!A:C" // datarange
),
"SELECT Col1 WHERE Col2=" & "'" & B2 & "'" // query
)
I had the same problem. This answer helped me find a workaround : https://productforums.google.com/forum/#!topic/docs/RxVUFGWQ2Y4
In my example :
1) In the spreadsheet where the data is I have added a few empty columns (E to H) in order to display 4 columns of data in 5 maximum rows.
=Query(Sheet1!A:D,"select * Where A contains 'KEYWORD' limit 5",1)
2) Then in the other spreadsheet:
=ImportRange("https://docs.google.com/spreadsheets/d/ss_key_here/", "'Sheet1'!E1:H5")
Not sure how to title this one... So please forgive me.
What we have is a POS sheet, I import POS data from Distributors then given the zipcode value it sorts the info and populates other sheets within the doc for each person responsible for the sale.
Sheet2 is the main POS sheet where all the data is imported into.
Rep Template is the sheet for any given rep responsible for the sale.
The Rep Template contains again a list similar to Sheet2 but only sales that apply to them (thanks to the zip code formula Im using). I However have on problem in this Rep Template. Im using a QUERY eg
=query(index(A19:F); "select (month(Col1)+1),sum(Col4), (sum(Col4)*.05) where Col1 is not null group by (month(Col1)+1) label (month(Col1)+1) 'MONTH',sum(Col4) 'TOTAL SALES',(sum(Col4)*.05) 'COMMISSION EARNINGS' ")
***See the highlighted yellow section #L9
This works fine
Q.What I would like to do is add this to it
but I cannot use (sum(D)*.05) again for another column...
=query(A19:F, "select (sum(D)*.05) where F != 'N' group by (month(A)+1) label (sum(D)*.05) 'ADJUSTED COMMISSION EARNINGS' ")
***see the highlighted orange section #N3
(Also why is this skipping down one cell that could solve a lot)
The thing is some commission for reasons xyz may be omitted once verified (hence F19:F) an "N" in COLUMN F will omit that line from the commissions resulting in adjusted commissions earnings.
Here is my Spreadsheet
https://docs.google.com/spreadsheet/ccc?key=0AqZjzFwBse-sdGZ4M3ppWVBuNTdJV3dYbGlwb0NUeVE&usp=sharing
Thanks everyone ; )
Please change Col1=A and Col4=D, it is right
use double-query:
=QUERY(QUERY(A19:F,
"select sum(D)
where F != 'N'
group by month(A)+1
label sum(D)''", ),
"select Col1*.05
label Col1*.05'ADJUSTED COMMISSION EARNINGS'")