Data not moving with importrange - google-sheets

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

Related

Split comma separated data into multiple rows

The data below pulls from another sheet in the same workbook. This data below will update over time and have more rows (so it is not static).
How can I "split" this data so each shipment ID has its own row?
For the first row, this would look like:
The implemented logic would need to work for each row in the first image which means row 2 (with Shipment IDs F,G,H,I) would be split into four separate rows. The logic would need to be dynamic to be able to split more rows as they are pulled in from the other sheet.
Ideally, I do not want to use a script.
try this out:
={A1:D1;INDEX(QUERY(SPLIT(FLATTEN(C2:C&"|"&D2:D&"|"&MAP(A2:A,B2:B,LAMBDA(ax,bx,IFNA(SPLIT(ax,",")&"|"&SPLIT(bx,","))))),"|",0,0),"SELECT Col3,Col4,Col1,Col2 Where Col3!=''"))}
if A and B column are independent use:
=INDEX(LAMBDA(x, QUERY(IFERROR(SPLIT(FLATTEN(TRANSPOSE(FLATTEN(ROW(x)&"×"&
SPLIT(x, ",")))&"×"&FLATTEN(ROW(x)&"×"&SPLIT(OFFSET(x,,1), ",")&"×"&
OFFSET(x,,2)&"×"&OFFSET(x,,3))), "×")),
"select Col2,Col4,Col5,Col6
where Col6 is not null
and Col1=Col3
order by Col2", ))
(A11:INDEX(A:A, MAX(ROW(A:A)*(A:A<>"")))))

Match lookup value with importHTML and combine tables in Soogle Sheet

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)))))
-

How can I combine multiple columns into one column in Google Sheets?

(Note: Please simply look at the Google sheet for the quickest understanding of what I'm describing in the below bulletpoints)
My data has rows which each represent an order
Each order (row) can consist of multiple products
For each product in an order (row) there is another set of columns in the same row
I need this data to convert into only one set of columns per row (i.e. one product per row)
The products (new rows) need to remain next to eachother so the columns can't just be added to the bottom of the array (which is more simple)
Can you please take a look at the example below and help me achieve this?
Example Sheet
Screenshot of linked sheet
Try this in another sheet
=SORT({query({Reference!$A5:$A,Reference!B5:F},"select * where Col2 is not null ");query({Reference!$A5:$A,Reference!G5:K},"select * where Col2 is not null ");query({Reference!$A5:$A,Reference!L5:P},"select * where Col2 is not null ")})

Copy from one sheet to another and copy to the next row

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.

Google Sheets - Query - Running Total below dynamic results

Testing Sheet:
Wondering if there is a witty way to add a Total to the last row +1 of
a Query result.
See Sheet 'Lookup' for a static example of what I am asking for.
I don't know if there is a way to have a hidden column that calculates
transposed only under the last row of a query, or if there is a smart
way to work Query for this answer.
All great answers. Each on very useful in its use case.
Макс Махров gets the answer with using a query statement.
Now I was not keen on having an extra sheet to hold the totals so I added a row at the top which I can simply hide and used this formula:
query({Orders!A:E;A1:E1},"select Col1, Col3, Col4 where Col2 = '"&C3&"' order by Col4",1)
Only problem I have is trying to figure out how to add TEXT to the bottom row, it seems to only want numerical input.
How do I fix this? What am I glitching?
Thanks !
Mars
The trick is to make second query and count totals for selected product.
Plan of actions:
add new sheet with query on it, something like this: =QUERY(Orders!A:E,"select B, 0, sum(D) where B like '"&Lookup!C2&"' Group by B",0)
Prepare arrayformula which combines data in Lookup sheet: = ArrayFormula({Importrange(1),Importrange(2)}) Note that number of columns must retain the same.
Edit query so it takes Col1, Col2, Col3... instead of A, B, C...
Make word 'total' visible instead of zero. Set number format: 0;0;total Set it for range B9:B on Lookup sheet
Make Conditional Formatting with formula =and($B4 =0,isnumber($B4)) for range A4:C on Lookup sheet.
That's seems have to complete the task.
Hope it Helps!
Your Example
Working example.
Here is one way:
Put TOTAL way down in row 1000
Select the range A3:C999. Select data > filter to create filters
Select C3, set the filter to hide all blanks
A second way is to limit the query result to show only the top 8 results:
Change your query to =query(Orders!A:E, "select A, C, D where B = '"&C2&"' order by D desc limit 8",1) It will reverse-order column D (largest first), and set row limit to 8.
Change the formula of your TOTAL to =sumif(Orders!B:B,C2,Orders!D:D)
Try this formula in the column adjacent to your query:
=ArrayFormula({$C$4:offset($C$4,count($C$4:$C),0,1,1);sum($C$4:offset($C$4,count($C$4:$C),0,1,1))})
It duplicates your column of values (I haven't figured out a way around that yet) and then adds a total to the bottom of that column, and changes dynamically with the range from your query.
Here's a working version.
Interesting challenge! It got the old grey matter turning... ;)
Thanks,
Ben

Resources