IMPORTRANGE() based on the date of another cell? - google-apps-script

I am trying to use IMPORTRANGE() to import a sheet from another spreadsheet. I am currently using the following formula.
=IMPORTRANGE("URL", B1&"!A1:R25")
However, I am getting stuck with the sheet name. B1 is a cell that shows a date, consequently I want to import the sheet with that date as its name. Also, B1 determines that date based on a formula; here it is
=(Leftb(Summary!$A$2,2)&"-"&Midb(Summary!$A$2,3,2)&"-"&rightb(Summary!$A$2,2))+7
I believe since B1 contains a formula like this, something is getting messed up in the importrange(), either the formula or the format of the date.

Your current formula gets the value of the date, not the date that is displayed in the UI.
Try this formula:
=IMPORTRANGE("URL", TEXTJOIN("",TRUE,B1)&"!A1:R25")

Related

Is there a function that saves the last value inputted with query?

=IF(Summary!H2="October",QUERY(Summary!L2))
Hello,
I was wondering if it’s possible to record the last inputted value with a query function
As seen in the code above, when October is selected in the summary sheet, cell H2 - the cell with the function (above) outputs what is written in the summary sheet, cell L2
When I select a different month, the cell (where the code is written) changes to FALSE
Is there any way to make value_if_false equal the last value inputted into L2 when the selected month is changed?
If further proof is needed please let me know
Thank you,
Gabe
example
Don't know if this is what you mean, here I have created an example, where data is stored in the 'data' sheet, and the QUERY function is placed in the 'main' sheet.
B1, B2 is the condition inputs, I assume you want to sort your data by date, in that case, you will need a start day and an end day.
the QUERY formula will be something like this:
=QUERY({data!A:F},
" WHERE Col1 IS NOT NULL "
&" AND Col1 >= DATE '"&TEXT($B$1,"yyyy-mm-dd")&"' "
&" AND Col1 <= DATE '"&TEXT($B$2,"yyyy-mm-dd")&"' "
)
With this QUERY formula, the output data will change according to the date selected in B1 and B2.
Just make sure that the date column of your data page is formatted as date, otherwise google sheet QUERY will not be able to recognize the data as date.
link of the sample spreadsheet

How to get the value from another sheet with variable sheet name using Google Sheets?

I need to get the sheet name from a cell.
On image below I'm trying to get '4/2'!$AB60.
need to get the date which is 4/2 (cell D5)
combine it with !$AB60
now the cell D6 will have a formula value of '4/2'!$AB60
it will display the value.
Is there a way to formulate this instead of what I currently be doing, manually updating the each column dates (from C6 to AF6)? Is this even possible?
Formula from the screenshot: =JOIN(,LEFT(D5,LEN(D5),!$AB60)
The problem with this formula is !$AB60 as it is not a valid value, instead use "!$AB60" or use =TO_TEXT(D5)&"!$AB60". To use the result of this formula as a cell reference use INDIRECT, i.e.:
=INDIRECT(TO_TEXT(D5)&"!$AB60")

How to import data from a sheet where sheetname is dependent on a cell value

I have been trying to make a Google Sheet for some purpose which shall have details of various movies.
Here is the link: https://docs.google.com/spreadsheets/d/10-4BWaK-zmTxmqr2ov7AvjQW-wAFR8NKXkICuCK1dTY/edit?usp=sharing
Now I wish to count the number of movies per year where sheet name is dependent on cell value.
For example, in Sheet: "Data" I wish that B2 shows the count of movies in Sheet named '2019' but I don't want it to be written as '=COUNTA('2019'!A:A). Instead I wish that the sheet name automatically gets picked up from cell A2. So if I change the year in A2, the Count in B2 should change automatically.
I tried using INDIRECT and MATCH function as =COUNTA(INDIRECT(A2,false)) and =MATCH(A2,INDIRECT(A2),1) but I think I made some errors.
Also in the same way I wish to count in C2 but with a condition: to count only those cells from G column where value is watched
In B2 try
=sumproduct(INDIRECT(A2&"!A3:A")<>"")
and see if that works?

Count the values from a variable column

I have a problem writing down a formula or a script in Google Sheet or Google App Script to find and count the values in a sheet where the number and references to the columns change.
I have a script that copy&paste the Sheet files for the staff shifts of every week from a Drive folder and merge them side by side (in horizontal).
In this sheet that contains all the shifts merged I want to count all the cells of the staff filtered only for handler and picker (column B, K, etc.) according to a specific date (row 3) for every hour.
Example: if today is 28/10/2020 find the right column with the same date in row 3 --> column E, count all the values from row 4 filtered by picker or handler for every hour (10 people at 05 AM).
Do you think that I can implement this with a formula (like a matrix, vlookup, etc.) or should it be written as a Script?
Thank you very much,
Marco
Please use the following
=COUNTA(QUERY({A3:I;J3:R},"select Col"&MATCH(A1,A3:I3)&"
where Col2 matches 'Technician|Picker' "))
Where B1 holds the date you wish to search for (28/10/2010)
Try the below formula. Replace date with your search date.
=COUNTA(INDEX(A4:R14,,MATCH(DATE(2020,10,28),A3:R3)))
This was earlier tagged as excel. This is how to "tackle" this in excel (office 365):
In a clear column use the following formula to get the unique hour-values that are in the column that equal today:
=UNIQUE(FILTER(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)),INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0))<>""))
In the column next to that type the following to get the result of the count of those unique values for that day:
=COUNTIF(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)), FILTER (I:I,I:I<>""))
Where I:I in FILTER (I:I,I:I<>"") needs to be changed into the column you put the first formula.

Max function not working on import range in google spreadsheet

I am new to google spreadsheet functions and trying to apply formula in following way:
I have an imported range as under in cell B2:
=importrange("1gRRBtq7KMAr5kY5AJBqFcLarkikqrAqr5CbeTc5mPzE/edit#gid","dstr!b2:b400")
This range contains different dates & I am trying to select last date with following function in B1:
=max(B2:B398)
But in place of showing date it is showing value.
Please help in solving this concern, for more detail you can go to following page:
https://docs.google.com/spreadsheets/d/1HTXf4VG2JupiP9UqCLRyAddYjhsom1leQOI9-DwfMaY/edit#gid=0
I selected cell B1 and clicked on the 123-button (in the menubar) and formatted that cell as date. See if that helps ?