=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
Related
I have a Google Sheet that I am writing a script for. My newest section of a macro code is supposed to fill column F with a weekday numerical value based off of column B which has values of date and time (MM/DD/YY hh:mm:ss). Once I added the section to the end of the macro code, it comes back with the Error Code "Exception: AutoFill destination range must extend the source range in only one direction." The code will add the value, but it doesn't correctly correspond to most days.
spreadsheet.getCurrentCell().setFormula('=WEEKDAY(B2, 1)');
spreadsheet.getActiveRange().autoFill(spreadsheet.getRange('F:F'), SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
spreadsheet.getRange('F:F').activate();
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.
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")
I have the following (simplified from original) formula which pulls in data from another sheet (multiple sheets in the original formula) and calculates the sum of a column based on the month() value of another column:
=QUERY({
IFERROR(IMPORTRANGE('C1'!$B$5, "PLACEMENTS!A4:L1000"), {"",TO_DATE(0),"","","","","","","","","",""})},
"SELECT SUM(Col8) WHERE Col2 IS NOT NULL AND month(Col2)+1="& MONTH($A3) &" AND Col1="""&B$2&""""& IF(NOT($C$1="ALL"), "AND Col6="""&$C$1&"""" ,)& " label SUM(Col8) ''",0)
I keep getting the #VALUE! Error:
Unable to parse query string for Function QUERY parameter 2: Can't
perform the function month on a column that is not a Date or a
DateTime column
If I remove the IFERROR wrapper to the IMPORTRANGE statement then the error goes away and as you can see, in the case of an error on the IMPORTRANGE statement, an empty array with Col2 set as a date with TO_DATE(0) is inserted.
This formula without the IFERROR works fine, and pulls in rows and provides a SUM value:
=QUERY({IMPORTRANGE('C1'!$B$5, "PLACEMENTS!A4:L1000")},"SELECT SUM(Col8) WHERE Col2 IS NOT NULL AND month(Col2)+1="& MONTH($A3) &" AND Col1="""&B$2&""""& IF(NOT($C$1="ALL"), "AND Col6="""&$C$1&"""" ,)& " label SUM(Col8) ''",0)
Here's a link to a sample sheet that the formula imports from with the same structure of data: Sample Sheet Data
If the Query works without the IFERROR wrapper, why does it produce the error about Col2 with the IFERROR wrapper in place which shouldn't be triggered in this case? This exact same formula works fine on another user's spreadsheet. Is this a Google Sheets/Query bug or is there something I'm doing wrong here? Thanks
IFERROR(exp1,exp2) is equivalent to IF(NOT(ISERROR(exp1)),exp1,exp2)
However, while the first option is not always compatible with queries, the second is more so.
In your case changing
IFERROR(IMPORTRANGE('C1'!$B$5, "PLACEMENTS!A4:L1000"), {"",TO_DATE(0),"","","","","","","","","",""}
to
IF(NOT(ISERROR(importrange('C1'!$B$5, "PLACEMENTS!A4:L1000"))),importrange('C1'!$B$5, "PLACEMENTS!A4:L1000"), {"",TO_DATE(0),"","","","","","","","","",""})
will solve the problem.
You have not shared the Sheet Snapshot you're working on, and it is hard to know what is happening in your formula.
Answer Updated
IFERROR function is giving {"",TO_DATE(0),"","","","","","","","","",""} incase first parameter is false and that is the array which is generating the error.
In the Query function in Select clause, you're doing Sum(Col8) which need a number for summation, but in array, at location 8 you're giving an empty string. You just need to add zero at index 8 {"",TO_DATE(0),"","","","","",0,"","","",""}
I'm trying to pull out only Salary Earnings from a Payroll tab to "Salary Earnings" column on Unique payroll tab using this "IF" function: =IF(Payroll!F2="Salary", Payroll!G2, " ") but for some reason it's skipping the salary on the same date as bonus.
I even tried the below one, and it's leaving D5, D6, and D7 empty.
=IF(AND(Payroll!F2="Salary", Payroll!C2=UniquePayPeriod!C2), Payroll!G2, " ")
Can anyone help please?
Thanks!
If I assume you're dragging the formula down in your UniquePayPeriod spreadsheet, then you may not be getting the "right" output, but you're getting the "accurate" output.
D5 will be blank because F5 is "Bonus", failing your if condition
D6 will be blank because Payroll!C6 is not equal to UniquePayPeriod!C6
D7 will be blank because Payroll!C7 is not equal to UniquePayPeriod!C7
This is happening because your Payroll sheet is listing Bonuses on separate line items with the same dates; after the first listing of a bonus, your Check Dates on your UniquePayPeriod sheet will not align with your Check Dates on the Payroll sheet
What you'll need to do is use Match and Index to look up the condition of ID, Check Date, and Salary, and then ID, Check Date, and Bonus.
This is the formula you need to put in your Salary Earnings Column
=IFERROR(INDEX(yourPayrollTable,MATCH(B2&C2&"Salary",yourIDColumn &
yourCheckDateColumn & yourEarnTypeColumn,0),7),"")
This is the formula you need to put in your Salary Earnings Column
=IFERROR(INDEX(yourPayrollTable,MATCH(B2&C2&"Bonus",yourIDColumn &
yourCheckDateColumn & yourEarnTypeColumn,0),7),"")
yourPayrollTable should be the range of data on the Payroll sheet
that has all your payroll information (Payroll!A2:G100 for example)
yourIDColumn should be the range of data on the Payroll sheet
that has all the IDs (Payroll!A2:A100 for example)
yourCheckDateColumn should be the range of data on the Payroll sheet
that has all the Check Dates (Payroll!C2:C100 for example)
yourEarnTypeColumn should be the range of data on the Payroll sheet
that has all the Earn Types (Payroll!F2:F100 for example)
These formulas are Array Formulas, so please make sure you press Ctrl+Shift+Enter after entering the formula and dragging it down, instead of just pressing Enter.
This can be a bit confusing so please comment if it does not make sense what you need to do