I have a Bill of Material.xlsx. I use to track the fabricated parts, purchased parts and electrical parts to make my life better. The BOM has many different sheets, but I will talk about two of them.
The first sheet is Called "Fabricated" where the drawing number and material, quantity and so forth. In that sheet column A8:A500 has a drop down list. In that list Vishay Redline, is my key trigger word.
The second sheet is called "Redline Fabricated". This sheet is were I will paste collect data from "Fabricated" so I can print it to give to the design engineers for changes. The array formula is looking for; "Vishay Redline" as the key lookup work, and then copy Cell 2,3,4, and so on, to the Redline Fabricated sheet. I did make a small change to that Arrayformula from my last post.
Here is my problem: if the Arrayformula find the (trigger work) on, let's say row 27, it will copy that data to the other sheet on row 27. And if the key word is found again on row 29, it will also copy it to row 29. So row 28 is blank. I want to collect data from one page no matter where it's at and paste it one row after the other. So when I print that page, everything will look neat.
The Array formula resides on the Redline Fabricated sheet A8:A500
=ARRAYFORMULA(IFERROR(VLOOKUP("Vishay Redline",Fabricated!A8:W8,{2,3,4,5,8,9,23},0),""))
Thanks for editing the post, and including the sample sheet. It's much more clear now.
Trying to skip blanks with vlookup is not simple (for me at least). I would do it with a query and importrange.
Try: =query({importrange("__YOUR SS KEY ID HERE__","Fabricated!A8:W")},"select Col2, Col3, Col4, Col5, Col8, Col9, Col23 where Col1 contains 'Vishay Redline'",0).
This should only bring in rows that have 'Vishay Redline' in Column A.
Related
I have a Google Form that collects a bunch of data from dropdown questions on a Sheet with each question going to one column (as normal). On separate sheets, I want to be able to count how many times each option is selected.
Here is an example of what the response sheet might look like. A, B, and C are all questions.
I would then have separate sheets for 'Person?', 'Place?', and 'Thing?'. The 'Person?' sheet would look something like this:
I want to be able to add in the count of each time the option appears for that question. In the example, notice that 'Napoleon" is in both Col A and Col C. If I just count the number of times 'Napoleon' appears, I will get '2' even though he only appears once in the "Person?" responses.
I originally used a QUERY function like =QUERY('Input Data'!1:1000, "select count(A) where A contains '"&$A2&"'",0). BUT, I need it to be dynamic. So the "Person?" question may not always be Col A. I want the Query (or whatever formula) to search the headers and only return the count of that option for that question even if the column location changes.
Okay, I figured it out! In case someone else is curious, I used this formula:
=QUERY({'Input Data'!A1:L}, "SELECT COUNT(Col"&MATCH("Person?", 'Input Data'!1:1,0)&") WHERE Col"&MATCH("Person?", 'Input Data'!1:1,0)&" CONTAINS '"&$A2&"' label COUNT(Col"&MATCH("Person?", 'Input Data'!1:1,0)&") ''",0)
Lee, I sent you a PM about your most recent post, but in the process, I came across this one. There is no need for multiple formulas or manual entry references. One formula can produce the entire report with headers, listing and counts:
=IFERROR(QUERY(FILTER(FILTER(A:L,A:A<>""),A1:L1="Person?"),"Select Col1, COUNT(Col1) GROUP BY Col1 ORDER BY Col1 LABEL COUNT(Col1) 'Count'",1),"No Matches")
Just fill in the header your looking for between the quotes where Person? is now.
The double FILTERs mean "Start with only rows where Col A is not null and Row 1 reads 'Person?'"
Then QUERY simply returns the unique names in the left column and their counts in the right column. Because the QUERY had a final parameter of 1, any existing header will be kept (in this case, the one you were searching for); and the created column will receive a header (i.e., LABEL) of Count.
IFERROR will give a friendly error message if no matches are found (in which case check that what you entered for the search in the formula exactly matches a column header in the range).
I want to automatically generate unique, incremented ids (SKUs) for products in my inventory using Google Sheets. These SKUs should be immutable and not change when the sheet is sorted. This screenshot shows my flawed attempt to do this:
The formula I have for column A is:
=if($B2<>"",$B2 & TEXT(COUNTIF($B$2:$B2,$B2),"-0000"),"")
That formula appears to give the desired result. However, if I sort by the values in Column C, SKUs become associated with different Item Names, which is a problem. How can I modify the spreadsheet to get immutable, auto-generated SKUs?
Update:
I would like to be able to add additional rows/SKUs to the sheet over
time
Here is a link to the sample spreadsheet
I've added a sheet ("InventoryMaster(Unsorted") to your spreadsheet.
This sheet would be used to add your prefixes and items only. Once added, you would never sort, insert rows, delete rows or items, etc. Just keep adding the next prefix and item into the next open row, in Col B and Col C. Col A has a formula that will create the static SKUs from that unchanging and ordered information. (I've hidden that formula-containing Col A, so that you only have to enter the manual data and don't have to worry about accidentally overwriting the formula or its results. It's still there at all times, serving its purpose in the background.)
Then, other sheets (see my added "Erik Help" sheet) can reference that "immutable" list, giving you the ability to sort without losing SKU connection.
Here is the A1 formula from the 'InventoryMaster(Unsorted)' sheet:
=ArrayFormula({"SKU";IF(B2:B="",,B2:B&TEXT(COUNTIFS(B2:B,B2:B,ROW(B2:B),"<="&ROW(B2:B)),"-0000"))})
And here is the SKU-assigning formula from A1 of the "Erik Help" sheet:
=ArrayFormula({"SKU";IF(B2:B="",,VLOOKUP(B2:B&C2:C,{'InventoryMaster(Unsorted)'!B2:B&'InventoryMaster(Unsorted)'!C2:C,'InventoryMaster(Unsorted)'!A2:A},2,FALSE))})
I have 2 sheets which are connected.
Sheet-1: Has ID column and Status column (Status field is manually updated by the team)
Sheet-2: Has ID column and Status column (+ many other fields)
Requirement: Status column in Sheet 2 to be updated from Sheet-1 if ID column in sheet-2 = ID column in Sheet-1
I wrote a Query and ImportRange, but I could find Query working only when I compare it against a static value (for e.g. Yes). What I want is it to check against the value in ID column from both the sheets and import only for rows that match.
=QUERY(IMPORTRANGE("1ZkPaYb1IIIkcbVerdmZ-Ru1vxFu1YMWj74QNQj2jles", "Ops Action Sheet!B2:B10000"),"select Col2 where Col1 = 'Yes'")
This doesn't directly answer your question about using QUERY, but I believe that that function might not be the best tool for what you're trying to do.
I write below a solution using the alternative function VLOOKUP.
I am assuming here that by "Sheet-1" and "Sheet-2", you actually mean entirely different spreadsheets, judging by your use of IMPORTRANGE.
If you don't mind having a copy of Sheet-1's contents living within Sheet-2, here is what you can do:
On a new sheet (tab) in Sheet-2, copy this function (fill in sheet_1_url):
=IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B")
You should see a copy of the data from Sheet-1 in that tab. You can hide this tab or protect it if you wish.
On your main data tab within Sheet-2, copy this formula in your Status column (assuming that your ID is in A2:
=IFERROR(VLOOKUP($A2,range_from_step_1,2,),)
Copy that formula down as much as you need.
However, if you don't want to have a copy of Sheet-1's data in Sheet-2 for whatever reason, you can simply skip steps 1-2 above, going straight to step 3, with the following formula in Sheet-2:
=IFERROR(VLOOKUP($A2,IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B"),2,),)
Not that I recommend it, since you'd technically be importing your data virtually within the formula N number of times, which will be a huge performance hit.
You can see the references for the formulas used above here:
IMPORTRANGE
VLOOKUP
IFERROR
edit to reflect and paste in spreadsheet 2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, IMPORTRANGE("ID", "Sheet!A:C"), {2, 3}, 0)))
A2:A - column of IDs in spreadsheet 2
Sheet!A:C - column A of this range hosts IDs
{2, 3} - brings column B and C from spreadsheet 1 into spreadsheet 2
I have imported some data into columns A-D using QUERY and IMPORTRANGE which is sorted asc by column A (Last name). I then want to manually add data into columns E-P. However as the original sheet is updated with new users and those new people are added to my spreadsheet, my manual data stays where it is and then belongs to the wrong person.
So if someone is added with the last name that starts with A, all the names are shifted down a row, but all the data stays in the original row. So Mr. A was added to row 2 with Mr. B's data instead of a blank row.
Is there a way to tie the data together?
This is my current function:
=QUERY(ImportRange("Sheet ID","Sheet!A:F"),"Select Col1, Col2, Col6, Col5 Where Col1<>'' and Col6 contains 'Qualifiers' Order by Col1 asc")
I want columns E-P of the new names that are added by the importrange to be blank and all the data in columns E-P to be shifted down with every person.
this is standard behaviour of Google Sheets. to counter displacement of data across rows you are supposed to implement a simple ID system and use VLOOKUP to bring up the right data for the right rows.
where Tab A!A:B will be your QUERY and Tab B!B1:B will be your E-P data and ID is the link in between harnessed by VLOOKUP formula. also you will need to change 2 to {2,3,4,5,6,7,8,9,10,11,12} coz having 2 will return you only the first ("E") column
I have 2 google workbooks. One is a rate sheet and the other is a vendor list with pricing.
I have the vendor list with pricing workbook linked to the rate sheet workbook via importrage command. This works great and everything updates as it should until you add a new line or remove a line to the rate sheet workbook. At this point the vendor workbook does not update the reference and just still points at the same lines it was originally, now displaying the incorrect data.
How can I dynamically have the vendor list workbook notice the addition or removal of lines in the rate sheet workbook and update the importrange formula?
Can this be done?
Any help is greatly appreciated.
EDIT: I have prepared 2 sample workbooks. They are Test sheet 1 - Rates and Test Sheet 2 Lanes
I have all of our rates in the first sheet. In the second we would have vendor lanes. This sheet consists of multie tabs all with an individual lane that is linked to 1 row in the rates sheet.
In the lanes sheet I have linked the two together via importrange in cell A8. Now this works and links properly, that is until you insert a new line in the rates sheet above the one the lane is linked to and then it doesn't update but shows what the new line information is.
Is there a way to have the lanes sheet dynamically update to the next line when a new line is inserted in the rates sheet?
two sheets links are as follows:
Rates
Lanes
Solution 1 - if you need to check only one condition
To achieve desired result you have to have something like an ID for every rate. For sake of this answer (based on your example sheets) I assume that this could be an Origin City. In Test Sheet 2 I have added new sheet - SheetTest where:
First step
I am looking for the row number where desire City reside in Rates sheet (in example - its Mcclellan city). The code for that is simple:
MATCH(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q/edit","Rates!B:B"),0).
This gives me -> 10
Second step
I use this result to dynamically generate final range - "Rates!A10:X10". The final result in A8 cell is (to make it clearer, I change an address of a sheet to -othersheeturl- :
=IMPORTRANGE(
"-othersheeturl-",
"Rates!A"&
MATCH(A2,IMPORTRANGE(-othersheeturl-","Rates!B:B"),0)
&":X"&
MATCH(A2,IMPORTRANGE("-othersheeturl-","Rates!B:B"),0)
)
Working example
Warning
I see that in your original sheet you use "take" Origin City from Rates sheet, so I remove this dependency in A2 to make it an ID. I hope this solves your problem.
Solution 2 - if you need to check many conditions
An approach is the same, but tools are different. Main goal is to find a row number that meets criteria - "From City" and "To City". Then this row number will be used to concatenate desire range.
First step - some cleaning
To better manage complex formulas its a good idea to divide them into smaller pieces - like in "ordinary" programing. So, we have:
From City in A5
New Albany
To City in B5
Calgary
Rate sheet (external sheet) url in B1:
1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q
You don't have to put whole URL, only this part is needed
Formula that counts row number that we are looking for in B2
=QUERY(
{IMPORTRANGE(B1,"A1:B"),
ArrayFormula(row(INDIRECT("A1:A"&ROWS(IMPORTRANGE(B1,"A1:B")))))},
"select Col3 where Col1='"&B5&"' and Col2='"&A5&"'
limit 1")
Above code:
Build an array from Rate sheet (external) - columns A1:B and virtual index that represents rows numbers
Then, show only column nr 3 (index) where Col1 matches our "To City" and Col2 matches "From City"
At the end is a limit to only one result (in case that there are more then one maches)
Desire range in B3
="Rates!A"&B2&":X"&B2
Final formula that renders desire data from external sheet in A11
=IMPORTRANGE(B1,B3)
Working example
Final thoughts
You can either hide rows 1-3 or you can pack all above formulas into one. Its up to you. I prefer the first approach.
This solution gives you freedom with as many conditions as you want
More info would be helpful.
A couple ideas:
Using named ranges instead of a static reference. For example, if you create a named range in the rate sheet called MY_DATA that references A2!C600, you can include "MY_DATA" in your importrange in the vendor sheet. Note that you'd still need to update MY_DATA every time you add a row.
If you're importing the entire sheet, perhaps omitting the end row would work (e.g. A2!C instead of A2!C600) - note that this means you need to use filter or query in the Vendor sheet to eliminate the blank rows.