Get last value of selected row in Google Sheets - google-sheets

I am trying to automatically find the last column in the current row with values. I want to do this because some rows have more columns than others. Here is the
Spreadsheet I am taking data from
.
Here is the query I have right now. I am getting circular dependency issues.
=QUERY(IMPORTRANGE("redacted_link","PriceList!A1:AZ100000"), "Select "&IFERROR(LOOKUP(9^9,(INDIRECT("R[0]C1", FALSE)):(INDIRECT("R[0]C50", FALSE))))&" where Col1 = '"&(INDIRECT("R[0]C1", FALSE))&"'",1)
This part: where Col1 = '"&(INDIRECT("R[0]C1", FALSE))&"'",1) already works and is effective at getting the value of column 1 in the current row.
&IFERROR(LOOKUP(9^9,(INDIRECT("R[0]C1", FALSE)):(INDIRECT("R[0]C50", FALSE))))&
I think this is referencing the current file instead of the spreadsheet I am taking data from.

try:
=INDEX(REGEXEXTRACT(TRIM(FLATTEN(QUERY(TRANSPOSE(IMPORTRANGE(
"id", "PriceList!A1:AZ100000")),,9^9))), "\d+(?:.\d+)?")*1)

Related

Count data between two data ranges

I've spent countless hours trying to count this data between two date ranges. I'm using a formula I've previously used in the past, but with no luck.
(Fixed - Sample Data - see updated Actual Data below, formula is not working with actual data)
Current Formula vs. Expected Results
=Query(flatten(filter(E3:E11,D3:D11>=D16,D3:D11<=E16)), "Select Col2,count(Col2) where (Col2 is not null) group by Col2 label count(Col2)''",)
I've tried:
COUNTIFS but could not find how to include criteria.
Using INDIRECT with named range in the 'Expected Results' Reason 1 - Reason 5 Column and COUNTIFS in the column to the right.
Googling over 50+ different sites and formulas.
(Updated: Actual Data) (Error - Not working)
[Current Formula and Empty Result]
(https://i.stack.imgur.com/SnRkm.png)
The actual data is being pulled from the Data sheet. The data on this sheet looks like this
Data on the Data sheet that's pulled onto the date filter sheet
(https://i.stack.imgur.com/yZNh9.png)
and is using this formula:
=ARRAYFORMULA(TRIM(QUERY(SPLIT(FLATTEN(IF(IFERROR(SPLIT(O11:O, ","))="",,TEXT(J11:J,"MM/DD/YYYY")&"×"&L11:L&"×"&M11:M&"×"&N11:N&"×"&SPLIT(O11:O, ","))),"×"),"where Col2 is not null")))
Solution:
I used the same code I previously used. However, the dates that were being selected could not be selected with the data that was being pulled.
I used:
=INT(O3)
to copy the date into another column, dragged the formula down, and used the filter to select the date from this new column. The date filter then worked.

Use dynamic created Query text as a Query formula in Google Sheets [duplicate]

This question already has answers here:
Stacking Multiple Arrays In Query/Lambda Function
(2 answers)
Closed 3 months ago.
First of all this is my first question here...
Ok, and now my problem:
I created a formula that generates a dynamic Query if you are searching for data in multiple sheets. I just write the names of the sheets in green field and it changes the Query.
The text for the Query is correct, but now I want this to by the actual formula in a cell to display the data.
If I use the = and add the cell with the Query text, it copy the text. I tried the INDIRECT formula, but it does the same.
How can I use a this dynamic text to be my Query to dispaly the data depending on the amount of names in the green field?
EDIT: As advised by user doubleunary (as mentioned, this is my first time), I'm going to rephrase the problem.
In an spreadsheet a manager imputs for every task the amount a worker has made. He creates an new sheet for each date and imputs the data for that day. Each day can have different rows of data. The boss wants a spreadsheet that display in one sheet all that has been done in the current month. I used Query because you can easy join data from multiple sheets and ignor the empty rows.
But the problem is, that every day a new sheet is added with a new "name" (date). And the easyest way I found tho make a dynamic Query, without the Boss to manualy edit the Query, was to create a text with TEXTJOIN formula, in witch he ony needs to enter the new "name" (date).
If there is a better was, please share, but it should not be in App Script if possible.
Thank you.
Easily you can't transform a text into a formula.
In this case, you should create the query formula and insert the ranges with Indirect function, like this:
=Query({Importrange(LINK,Indirect("'"&O4&"'!I38:S107"));Importrange(LINK,Indirect("'"&O5&"'!I38:S107"))},"Select * Where Col1 is not null",0)
If the formula you quote and the data sheets are all in the same spreadsheet file, you should not to use importrange() but indirect(), like this:
=query(
{
indirect(O4 & "!I38:S107");
indirect(O5 & "!I38:S107")
},
"where Col1 is not null",
0
)
In the event the row references such as I38:S107 change from time to time as well, you can put those references in a cell and refer to them the same way.
try (assuming url is same for all sheets):
=QUERY(LAMBDA(x, QUERY(REDUCE(SEQUENCE(1, 11), x,
LAMBDA(a, c, {a; IMPORTRANGE("url", c"!I38:S107")})),
"where Col1 is not null", 1))
(O4:INDEX(O:O, MAX((O:O<>"")*ROW(O:O)))), "offset 1", )
more examples: https://stackoverflow.com/a/74280310/5632629

Copy a data range and then insert blank rows every after a certain value

I'm copying a range of data (one column only) using QUERY(), however, I am trying to find a way to insert blank rows whenever a certain value is shown.
here, I'm trying to insert 2 blank rows whenever the value b1 shows. I've been trying to accomplish this with some query() and arrayformula() formula but I'm not getting close. We're trying to complete this using formula only (no scripts)
Here's the sample sheet
My solution is:
=query(flatten(ArrayFormula(split(transpose("b1 & & "&split(ArrayFormula(textjoin("&",1,A5:A)),"b1",0,1)),"&",1,0))),"select Col1 where Col1 is not null offset 2")
This is not perfect as there are spaces instead of blank rows. But I hope it might help you.

IMPORTRANGE: value missing?

I have been working on this issue for a few weeks now and can't seem to find a solution. I used this answer (IMPORTRANGE with CONDITIONS) to get as far as I could, but I keep getting a value error.
This is the sheet I'm working with.
My goal is to use the first tab in the sheet (All Games) to enter all the games that I come across to create a compendium. But, then I want it to automatically populate the other tabs based on certain criteria (what type of game, skills learned, etc.)
On the Warm-Ups tab you'll see the formulas I have tried. A1 is the most recent.
Here is the formula I tried:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag/edit#gid=1359689553", "All Games!A1:A1300"),"SELECT Col1 WHERE (Col2 = 'w') ")
I am getting a value error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Col2
you are trying to reference Col2 but you selected range A1:A1300 which is just 1 column. therefore try:
=QUERY(IMPORTRANGE("1F64PMg_iFu-DaJAUaE4BkpqF4zoteknp56VfwAUe8ag", "All Games!A1:B1300"),
"SELECT Col1 WHERE (Col2 = 'w') ")
from the brief look on your sheet, you may want use matches or contains instead of = in your QUERY
You are only importing (part of) ColumnA - so no wonder Google can't find a second column :)

Google sheet query / filter with columns not Blank

I'am working on some document which get data from Non Google form, and the output is 36 column but there will be always filled up 8 max 9 columns with empty columns in between, with our Form we CANT change way how data are outputed. Empty column are here cuz Client fill up specific type of order so data are put in specific column.
i need query for pulling data from the main sheet and output just specific 5 specific column ( those will be always in same place ), and 2 columns that can be anywhere in between.
writing down every single column is not perfect as i need to pull data row by row not all at once ( i will be adding data in between final query output) and with that it would drasticly slow down file with few hundreds inputs added per week.
I didnt found working way to combine filter and query together to do this job ( removing empty columns [ <>'' and is not null].
Could someone help me with this ?
providing link for file : https://docs.google.com/spreadsheets/d/1SDR939yUSq9trLcxBid9AQeZUn-lNNiRr7O7pDiu888/edit?usp=sharing
In cell M1 of your sheet 'Desired output' try entering this little monster
=Arrayformula(query({'Raw data'!A:Z\
{"Configurable list"; 'Raw data'!D2:D&'Raw data'!F2:F&'Raw data'!H2:H&'Raw data'!J2:J&'Raw data'!L2:L&'Raw data'!P2:P&'Raw data'!R2:R&'Raw data'!T2:T&'Raw data'!V2:V}\
{"Date"; ('Raw data'!E2:E&'Raw data'!G2:G&'Raw data'!I2:I&'Raw data'!M2:M&'Raw data'!O2:O&'Raw data'!Q2:Q&'Raw data'!S2:S&'Raw data'!U2:U&'Raw data'!W2:W)+0}};
"Select Col1, Col2, Col3, Col26, Col28, Col24, Col27 Where Col1 is not null format (Col28) 'dd.mm.yyyy'"))
See if that works for you?
Your answer is really in the heading. You can use =filter([Range], [Range]<>"") for each row to get to this in the desired output. The filter function is perfect for this application.
UPDATE:
Looked at your sheet to get a better view of the problem. You'll need some wildcard workaround as shown here as a second criteria to identify the Date & Configurable cells: =filter([Range], [Range]<>"", search("Date", [Top row]))

Resources