I have been working on querying multiple sheets of data and would like the text string from one of the cells to determine which sheet that row is querying but can not figure out how to do it. This is the most recent formula I have tried:
=QUERY(INDIRECT("B"&"2")&"!"&$2:$1000)
Cell B2 contains the name of the other sheet I am trying to query.
try:
=QUERY(INDIRECT(B2&"!2:1000"))
or:
=QUERY(INDIRECT(B2&"!B2:B1000"))
Related
Currently, I have a summary excel tab in my workbook where I am hardcoding the sheetname to get a count from it as follows:
=COUNTIF('SheetName1'!$D:$D,E$2)
I have the sheet name in the adjacent cell as well.
I have been trying to figure out how to dynamically link it with the adjacent cell value:
Something like =COUNTIF('&B3&'!$D:$D,E$2)
Edit: Easier test sample is COUNTA instead of COUNTIF: =COUNTA('SheetName1'!$A:$A)-1
The problem is the same
You need INDIRECT() function-
=COUNTIF(INDIRECT(B3&"!D:D"),E2)
For above formula B3 contains sheetname and E2 contains criteria data.
I would appreciate some help, please.
I have a google sheet with many tabs with data going horizontally.
I would like to create a formula that imports and transposes the data into a vertical list.
However, I want to be able to type in (or drop-down list) to select the tab which the transpose formula to look at. I cannot get anything to work. I have tried this
=TRANSPOSE(A1&!B2:J2)
To add to that if it could use a lookup (vlookup or hlookup) to find the correct row to transpose then that would be great also.
I have set up a test sheet below. Please help. Many Thanks Tim https://docs.google.com/spreadsheets/d/1Menn6Z1mLl8wYOrcdQFnfs7Lp0dbC9UJe1S3AQRcOS0/edit#gid=0
You should not use IMPORTRANGE to work with data that exists anywhere in the same spreadsheet. IMPORTRANGE is for use retrieving data from a separate spreadsheet.
Instead, delete your current Sheet1!A2 formula and replace it with this:
=ArrayFormula(TRANSPOSE(INDIRECT(A1&"!B16:J16")))
I also added a new sheet ("Erik Help") with an advanced formula that accomplishes your lookup using whatever is types in B1. If whatever is typed in B1 exists in Column A of the selected sheet, the results of that row will be retrieved. If no match is found, IFERROR will return "No Match Found."
That formula, in 'Erik Help'!A2:
=ArrayFormula(IFERROR(QUERY(TRANSPOSE(INDIRECT(A1&"!B"&VLOOKUP("*"&B1&"*",{INDIRECT(A1&"!A:A"),ROW(INDIRECT(A1&"!A:A"))},2,FALSE)&":"&VLOOKUP("*"&B1&"*",{INDIRECT(A1&"!A:A"),ROW(INDIRECT(A1&"!A:A"))},2,FALSE))),"Select * WHERE Col1 Is Not Null"),"No Match Found"))
I have 15 Google Workbooks that import into 1 Workbook tab through an Importrange + Query combo function. The data is then queried and transformed across several other tabs, but the problem definitely begins on this tab.
Although I've manually forced a format change to "Number" in each workbook source AND in Columns CO:CQ (where the problematic data lands), all functions see the data as zero or null. Here is what happens when I set a random cell (CW33) equal to a cell in one of the trouble columns (CO33)
However, when I wrap the cell in an =sum(), the workbook returns "0":
I have no idea how to force the workbook to see the values in these rows as numbers without creating an entirely new column - does anyone have any ideas on how to fix it while preserving the column structure?
Thanks!
try:
=SUM(CO33*1)
for multiple cells it would be:
=ARRAYFORMULA(SUM(CO33:CO34*1))
or:
=SUMPRODUCT(CO33:CO34)
AFAIK, in Sheets, a Number formatted cell displays contents right-aligned and Plain-Text are left-aligned. The highlighted cell looks like a text cell.
Try changing the format of cell or column manually to 'Number' from the 'Format' tab.
Is there any way that without importing the data in helping sheet we can use vlookup as I have created in Sheet1 to lookup the values from other sheet “Directly” by using IMPORITNG (Query formula?
Here is current formula.
=ArrayFormula({"Comments";IF(A2:A="","",IFERROR(VLOOKUP(TRIM(A2:A)&B2:B&"|"&C2:C&D2:D,{TRIM('Sheet1 Import'!A2:A)&'Sheet1 Import'!B2:B&"|"&'Sheet1 Import'!C2:C&'Sheet1 Import'!D2:D,'Sheet1 Import'!E2:E},2,FALSE),"*** NOT FOUND ***"))})
But above formula is taking the data from helping sheet I am trying to create a formula that directly match the result and take relevant data from another sheet.
I have created this formula but its not working ?
=INDEX(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1x7ofB9Rt-y5_DlaxQVIZK_ZKR8sqBHVxAu3ZZlU13YA/edit#gid=0", "Sheet1!E:E"),MATCH(1,(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1x7ofB9Rt-y5_DlaxQVIZK_ZKR8sqBHVxAu3ZZlU13YA/edit#gid=0", "Sheet1!A2:A")(B2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1x7ofB9Rt-y5_DlaxQVIZK_ZKR8sqBHVxAu3ZZlU13YA/edit#gid=0", "Sheet1!B2:B")(C2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1x7ofB9Rt-y5_DlaxQVIZK_ZKR8sqBHVxAu3ZZlU13YA/edit#gid=0", "Sheet1!C2:C"),0)))))
Sheet links
https://docs.google.com/spreadsheets/d/1x7ofB9Rt-y5_DlaxQVIZK_ZKR8sqBHVxAu3ZZlU13YA/edit#gid=0
https://docs.google.com/spreadsheets/d/1_9Vumt1a-1WnrXAHOpJd1GUTQ3jLjPifwGyKlDDRyi0/edit?usp=sharing
From the question
Is there any way that without importing the data in helping sheet we can use vlookup as I have created in Sheet1 to lookup the values from other sheet “Directly” by using IMPORITNG (Query formula?
One way is to add the VLOOKUP formula on the source spreadsheet then import the result. Another way is to use Google Apps Script.
I have two sheets that I want to link using a "primary key". At the moment, I have imported from sheet1 into sheet2 some columns using the function
=Sheet1!A1 (for the first cell for instance). My purpose is to complete the data related to each imported line in sheet2. However, sheet1 is shared with other people, thus they can modify the content of a line without deleting or modifying the data I have added in sheet2 (and that doesn't exist in sheet1).
Given the fact that my table has a column 'id' that can be considered as a primary key, how can I add new data in sheet2 in so far as it will be related to the 'id' rather than the position of the line (so if I ever change an id in sheet1 the data I added will be deleted or if I move an id to another line, all the data will be moved too)?
you can use VLOOKUP and bring over data based on ID, like:
=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, Sheet1!A1:B, 2, 0),))
for more columns add them in an array:
=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, Sheet1!A1:B, {2,3,4,5}, 0),))
demo spreadsheet
I like player0's answer, but I found this easier to understand:
=QUERY(data_to_search,"select column_you_want_to_show where other_sheets_primary_key_column='"&this_sheets_primary_key_column&"'")
e.g.
=QUERY(Sheet4!$A$2:$F$10,"select F where A='"&$A2&"'")