Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I've got two sheets, say "Products" and "Price", in both sheets there is a column "productid". I want to have a new column in sheet "Products", say "new_price" and get it from sheet "price".
Using SQL it would be no brainer:
select a.col1, b.price as 'new_price' inner join products as a inner join price as b on a.productid = b.productid
how to do it right in the google sheet?
The QUERY() function is modeled after SQL and is very powerful. However, not all SQL is supported such as JOINs. There are complicated formulas that can do that using various combinations of functions. I decided to write my own JOIN, I called it denormalize.
Here are some examples of usage:
=denormalize("Employees","Orders",1,3)
=denormalize("Employees","Orders",1,3,"full")
=QUERY(denormalize("Employees","Orders",1,3,"left"), "SELECT * ", FALSE)
You can get the complete custom function with lots of examples here:
https://docs.google.com/spreadsheets/d/1vziuF8gQcsOxTLEtlcU2cgTAYL1eIaaMTAoIrAS7mnE/edit#gid=0
Make a copy and check out the custom function in the script editor.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
Suppose there's a website that has a list of details of some companies, for example, name, HQ area, turnover, etc. How do I scrape that data and fill it into different columns (like name, turnover) with each row having the details of a separate company?
Google Sheets allow you to import html tables or list with the IMPORTHTML(url, query, index) function.
For example, using the Wikipedia page List of largest companies by revenue as an example.
We want the data from the main table, so the first thing that we have to do, is to know what index it occupies in the page. To do this, we can use document.querySelectorAll('table') or $$('table'), as you can see from the result, the table that we want is in the position 5 of the array, so inside our google sheet we can use:
=IMPORTHTML("https://en.wikipedia.org/wiki/List_of_largest_companies_by_revenue","table",5)
From here, you should change the query parameter to list and find what index it occupies within the page using the method described above. In any case, you could always use IMPORTXML(url, xpath_query), and knowing the XPath of the information, you could come up with a similar solution.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to display the values according to the text that which is comes in the drop-down list. one of my friends from this platform helped me to develop that. But that function is only displaying based on two texts. can I add it one more text to generate details?
Here I'm adding the sheet for more clarification. Take a look and you will understand what I need. I want to display which comes under "insurance claim" when we select yes/no.
https://docs.google.com/spreadsheets/d/1VsLKHSZsTMeBctnINnsixKISgNkTHDV-dkO4ORsDjgI/edit#gid=595280251
You just need to add the and F contains '"&$C2&"'" to your current formula on the cell A5 of the sheet RESULTS.
For more details please see the Query documentation
Your cell A5 will become this:
=query(LIST!A1:G,"Select * where B contains '"&$A2&"' and C contains '"&$B2&"' and F contains '"&$C2&"'")
If you want to have the values of both sheets in your RESULTS sheet, you can add the other sheet to the range of the query:
=query({LIST!A1:G;LIST2!A1:G},"Select * where Col2 contains '"&$A2&"' and Col3 contains '"&$B2&"' and Col6 contains '"&$C2&"'")
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to use VLOOKUP function between two different sheets in two different spreadsheets.
In the "range" parameter of VLOOKUP I have inserted a range via IMPORTRANGE(different_spreadsheet_url, range_string) and I got null value, although the value that I search for is appear in the input range.
I think there is some problem with using IMPORTRANGE inside VLOOKUP but I can't figure it out.
I would be happy if anyone can help me with this or suggest another way to solve my issue.
Thanks.
You have quite the unusual problem for the following reasons:
You want to use a VLOOKUP, but select a column to the left, which VLOOKUP doesn't like.
You can't use the usual INDEX-MATCH workaround because you want to use an ArrayFormula, which works with VLOOKUP, but not INDEX.
So what we need to do is swap the columns from your source sheet before using VLOOKUP. We can achieve this with a QUERY and select the Columns in reverse, like so:
=ArrayFormula(VLOOKUP(FILTER(A:A,A:A),Query(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1nGI6-Vwv_zX-0DfN8zFwVYJTd00iXY3HLcSlU_rjhEo/edit#gid=0","example1!A:B"),"select Col2,Col1"),2,0))
Or more readably:
=ArrayFormula(
VLOOKUP(
FILTER(A:A,A:A),
Query(
IMPORTRANGE(
"https://docs.google.com/spreadsheets/d/1nGI6-Vwv_zX-0DfN8zFwVYJTd00iXY3HLcSlU_rjhEo/edit#gid=0",
"example1!A:B"
),
"select Col2,Col1"
),
2,
0
)
)
I also went ahead and used all non-blanks of column A using FILTER as well, so you can expand your data if needed.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Hell,
I encountered one problem while combining different sheets(tabs) into one master sheet, e.g I have three sheets named Cola, Pepsi & Thumbsup, I consolidated their results all in my Master sheet using Query formula with null. Whenever anyone entered data in Cola, Pepsi & Thumbsup sheet it comes to my master sheet somewhere in Between the rows. I need it to comes queue wise, is it possible?
The problem I faced is, I am writing a remark on my master sheet on each entry so whenever someone added new data in Cola, Pepsi & Thumbsup it inserted in between the data and break the sequence of my remarks.
The remark I wrote for e.g Cola 103 it shift to cola 102 when someone enters new data in cola sheet.
About the query, it just displays the values. It's kind of impossible to control as your mention. I recommend to use app-script (macro), function append or getValue setValue or getRange copyto as text paste not just display
If your data have timestamp each row. It might work, sort by depending on date and time added. Need to use just one column sorted. In function query ...order by A asc
Anyways, I still recommend to use app-script (macro)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
https://docs.google.com/spreadsheets/d/1mvBFBuRUl2qiPktE1Y4lCTeaSK4BwJ7S4Nf0S33LTRg/edit?usp=sharing
On Sheet2 I am wanting to show all the columns associated with a specific string that comes from a dropdown data validation. I have tried using VLOOKUP but that only outputs the first entry found, I want to print every entry along the row.
I put an example of what I am trying to get it to look like but not sure if VLOOKUP or QUERY or FILTER or something else is what I need
In your example spreadsheet, sheet 2, delete everything in the range F3:I and then enter in F3
=query(A:D, "where D='"&F2&"'",1)
If you want to reference the data on the sheet you'll have to use
=query('Draft Board'!A:D, "where D='"&F2&"'",1)
See if that works ?