Match lookup value with importHTML and combine tables in Soogle Sheet - google-sheets

I have total 2 url links both of which match lookup value and want column of second table in first table.
I have first taken a table from the importhtml formula. And the cell that is green is the column lookup value. Which is as follows.
1st table https://www.screener.in/screens/881782/rk-all-stocks/?page=21
=QUERY(IMPORTHTML("https://www.screener.in/screens/881782/rk-all-stocks?page=1", "table",1),"where Col1 is not null",1)
And there is another table in which I want to match the lookup values from the first table and all the values from that table. Which I have tried. Within this google sheet and you can also try in this google sheet.\
=VLOOKUP(B3,IMPORTHTML("https://www.screener.in/screens/881791/rk-holding/?page=1", "table",1),12,0)
2nd table https://www.screener.in/screens/881791/rk-holding/?page=1
In column next to roce I want column of promoter holding. Which you have to take from this url link.
get result like
try this in google sheet. : https://docs.google.com/spreadsheets/d/1yawdkBHkheaXeziWHFBFd3gngO3EQJr0d19lUH9cVfI/edit?usp=sharing
Thanks in Advance.

added formula to your sheet
Cell L3:
=BYROW(B3:B,LAMBDA(bx,IF(bx="",,IFNA(QUERY(IMPORTHTML("https://www.screener.in/screens/881791/rk-holding/?page=1", "table",1),"Select Col12, Col13 Where Col2='"&bx&"'",0)))))
-

Related

Google Sheets Query Search Box | Search criteria

so basically I have a searchbox in my sheet that searches and pulls up data. For a reference see this image: https://i.imgur.com/MVTUCSw.png. So basically in cell A4 I put the data that I am looking for, but my formula restricts me to only looking up stuff in 1 row. For example, data starting with the word MELD, but I would like to be able to also look up data based on for example the someone their name.
The formula I use for the searchbox: =QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G}, "SELECT * WHERE Col1 "&Opzoeken!B4&" '"&A4&"'")
The data that I want to be able to look up is stored in 2 sheets: Pallets & Locaties - https://i.imgur.com/qV7h2tz.png and in Voorraadverschillen - https://i.imgur.com/foqLkKa.png.
The searchbox is only able to lookup data in row, but I just want to be able to search for any kind of stored data in any of the sheets.
Here is my sheet for reference: https://docs.google.com/spreadsheets/d/10wmnxV16JUiD_b_54abkiLPwTqLITWRcUw3gsqvXoBE/edit?usp=sharing
I'd recommend you add more rows for the lookup criteria and add a column for what column it would search for.
Sheet modification:
Formula:
=QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G}, "SELECT * WHERE "&TEXTJOIN(" AND ", TRUE, ARRAYFORMULA(IF(ISBLANK(A4:A10), "", A4:A10&" "&B4:B10&" '"&C4:C10&"'"))))
Test Sheet
Note:
The above formula will allow you to search on other columns with their own words and criteria to search.
Only rows with Kolom values will be included in the criteria. If you only need Col1 criteria, make sure to leave other rows blank.
This does use an AND search, meaning all of the criteria should be true and match the row. Feel free to use OR in the TEXTJOIN function if you only want to search all rows matching any of the criteria.
This will only search on sheets Pallets & Locaties and Voorraadverschillen. Add the necessary sheets if you need them.
EDIT:
Cleaned up the formula to not be so repetitive.
=IF(A4<>"",(QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G},"Select * WHERE "&textjoin(" OR ", true, arrayformula("Col"&ROW(1:7)&" "&B4&" '"&A4&"'")))),(QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G},"Select * WHERE Col1 IS NOT NULL")))
This searches every column for the data, as long as data is not identical in two columns you won't have issues. An example would be the search criteria "MELD" being in both Column A and B. If that were the case, only the results from the first matching column would populate.

Google Sheets Query using important range and a dynamic cell reference

I have a roster of students (Sheet 1) and I need a formula to search another sheet (Sheet 2) to see if each student on Sheet 1 is also on Sheet 2 and if they return the word "yes"/ if they are not I would like the cell to remain blank.
This is the formula I have:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1395p5J5oN4vYLPeyAdUQDZluwxWU53NYJPiqeHdXSEw/", "Quarter 3!A3:H"), "Select 'yes' where Col1="&$A7&"")
The formula is not working properly.
For students that are on Sheet 2 the formula is returning two rows of data (two rows of "yes) and the first instance of "yes" include characters that I did not include in the query:
For students not on Sheet 2, the formula is returning a yes with the extra characters "yes"().
I feel like I should be using an IF function, but I could not get it to work with IMPORTRANGE
use:
=QUERY(IMPORTRANGE(
"1395p5J5oN4vYLPeyAdUQDZluwxWU53NYJPiqeHdXSEw", "Quarter 3!A3:H"),
"select 'yes' where Col1="&$A7&"
label 'yes''')

Arrayformula not working with index and match google sheets formula

I have data in three columns. Column A contains a list of fruits. The second column the rank (1,2,3...) and the third column a list again but this time ordered by preference.
I want to return the rank in the fourth column. I have tried this formula which works as it should but it's returning just one value yet it's an array formula. What could be missing?
=ARRAYFORMULA(index(B2:B11,match(A2:A,C2:C11,0)))
Link to my spreadsheet.
https://docs.google.com/spreadsheets/d/1e7xCcdPa3MywDVs70o2kXAwMnzJRMDuucktWPowS_MY/edit?usp=sharing
Index doesn't work with array formulas so you have to use Vlookup instead:
=ArrayFormula(if(C2:C="","",vlookup(C2:C,A2:B,2,false)))

Data not moving with importrange

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

Sort the value of a column with a relative position (using an other column data order)

I've created a form to collect data from user A in a sheet and reformat it for user B in the other sheet.
I have to sort the data for user B. I'm using vlookup to sort the column of values from the form to a new sheet (sort based on the order of the 'value description column'). It's working.
My problem is that when a new column is added to the first sheet (the form) the column range is modified and the index parameter in vlookup is not good anymore. So I lost everything on my second sheet.
How can I do to have a solid link with the column in the first sheet even if it's position change?
you can make use of INDIRECT with COUNTA and SUBSTITUTE. something like:
=INDIRECT("Sheet1!A1:"&SUBSTITUTE(ADDRESS(1, COUNTA(Sheet1!1:1), 4), 1, "")
this will count non-empty cells in row 1 of Sheet1 and converts that number to later which is used in constructing the range put together by indirect formula and all of it can be placed in vlookup as same as you would place any ther regular range.

Resources