I've got a gSheet that is fed from form submission. Throughout the day, I need to calculate the duration automatically; subtracting the most recent timestamp from the previous timestamp of the same user in column E. Is this possible?
Sheet: https://docs.google.com/spreadsheets/d/1_gbM2TVpUDrGU0B0_s1_aiH2r-9l6TUPxwlzo2SW338/edit#gid=0
Use the formula in E2
=IF(B2="", ,IF(XLOOKUP($B2,$B$1:$B1,$A$1:$A1,"-",0,-1)="-","First time worker",$A2-XLOOKUP($B2,$B$1:$B1,$A$1:$A1,,0,-1)))
And drag it down till the end of the sheet
Use this formula
=IF(A2="",, SORTN(IF(
COUNTIF(B$2:B2, "="&B2)>1=TRUE,
SORTN(FILTER(A$2:A2,B$2:B2=B2 ), 2, , 1, 0), A2),1,,1,1))
Related
I'm going to be as clear as possible.
First of all I have 2 sheets:
Sheet 1: https://docs.google.com/spreadsheets/d/1AXPQyw_yZUfafjWNW82Rf9E02qR_0c_SYeKOnqQUUdE/edit?usp=sharing
Sheet 2:https://docs.google.com/spreadsheets/d/1v_AyqHXJVhzRNbL-yGoMLxnuKC3z67tZOcQAWwduCN0/edit?usp=sharing
Thank you for your help,
I'm feeling data in Sheet 1 for each week. In the example, I have week 49 and 50.
In Sheet 2, I have a tab for each week. I'd like to have a formula that based on the week number either from the tab name or from the cell A2 in my example, the formula check Sheet 1, look if there is some entries for the week in question and fill automatically the proper tab for the week.
Try this:
=QUERY(IMPORTRANGE("url";"Sheet1A1:E");"select * where Col1 matches '"&A2&"'");
I haven't tested it because the files are shared as Viewand I think that it at least puts you in the right direction.
References
IMPORTRANGE()
QUERY()
try:
=QUERY(REDUCE({""\""\""\""}; SEQUENCE(2; 1; 49); LAMBDA(y; x; {y;
IFERROR(IMPORTRANGE("1v_AyqHXJVhzRNbL-yGoMLxnuKC3z67tZOcQAWwduCN0";
x&"!A3:D100"); {""\""\""\""})})); "where Col1 is not null"; )
see: https://stackoverflow.com/a/74280310/5632629
and: https://stackoverflow.com/a/74483215/5632629
I have a database of customers, where his zone, seller and some other values can change, and I want to generate a table of the last occurrence of each one
Heres a demo sheet
using Vlookup doesn't get the last occurrence
My database is very big and I need something to not slow my sheet that much, because I was using a formula like this one for each cell
=ARRAYFORMULA(LOOKUP(2,1/(C2:C=A2),$D$2:$D))
but the sheet is very slow because of this
Any help on this please ?
use:
=ARRAY_CONSTRAIN(SORTN(SORT({C3:E, B3:B}, 4, 0), 9^9, 2, 1, 1), 9^9, 3)
I have a Spreadsheet with duration values in one column, and date values in another.
I want to sum duration values based on a particular day of the week... eg, in the example screenshot, the first and last dates are Friday. So I want a formula that would add the duration values from the corresponding cells... a total of 17:00
I've tried a formula like this. But this doesn't work.
=SUMIF(D:D, CHOOSE(WEEKDAY(DATE(),2), "Fri") , A:A)
You could try:
=sumproduct(weekday(A:A)=6,D:D)
try:
=TEXT(ARRAYFORMULA(SUMIF(WEEKDAY(A:A, 11), 5, D:D)), "[h]:mm")
Not sure if there is an easy way because I'm noob at Google Sheets, but try with array formula:
=ArrayFormula(SUMIF(D1:D3;WEEKDAY(A1:A3;2);5))
Using it as array formula, I got this:
Hope this helps
One approach to do this is the following:
In column E put the weekday values. Use WEEKDAY() function which depending on your setting will make Friday any integer between 1-7. If using default Friday will be "6".
Use the SUMIF() function. Eg.=sumif(E:E,"=6",D:D)
Make sure the cell where your SUMIF() formula resides, also has a duration number format.
I'm stuck with this assignment where I need to use index-match formula to input values from another sheet.
Google Sheet: https://docs.google.com/spreadsheets/d/182b4foaNURrAysA9pQ2rtFinU0U1TnwBDNHEkInbjiQ/edit?usp=sharing
I need to get value from Sheet "Mon-Sun" to show in the sheet "Work hour" using formula. My friend said I should use index-match, but I cannot seem to be able to do it (Only know how to do basic index-match). Been thinking for hours now but cannot find the solution. Please help.
Perhaps the following, which is just an INDEX with two MATCH's (ID and day of the week), and a bit of logic to handle your setup with merged cells, as well as whether it's Day or Night.
=index('Mon-Sun'!$B$3:$O$6,match($A4,'Mon-Sun'!$A$3:$A$6,0),match(if(isblank(C$2),B$2,C$2),'Mon-Sun'!$B$1:$O$1,0)+if(C$3="Day",0,1))
delete everything in range C4:Z
paste this in C4 cell and drag to the right:
=ARRAYFORMULA(IFNA(VLOOKUP($A4:$A, {'Mon-Sun'!$A3:$A, INDIRECT("Mon-Sun!"&ADDRESS(3,
MATCH(IF(C2="", B2, C2), 'Mon-Sun'!1:1, 0)+IF(C2="", 1, 0), 4)&":"&ADDRESS(ROWS('Mon-Sun'!A:A),
MATCH(IF(C2="", B2, C2), 'Mon-Sun'!1:1, 0)+IF(C2="", 1, 0), 4))}, 2, 0)))
I'm using Google sheets for data entry that auto-populates data from my website whenever someone submits to a form. The user's data imports into my sheet with a timestamp (column A).
Using the Arrayformula function, I'd like a column to autofill all the dates of a timestamp within that month. For example, if 1/5/2016 is entered as a timestamp, I'd like the formula to autofill in the dates 1/1/2016 - 1/31/2016.
Additionally, I'd like other months added in the Arrayformula column. For example, if both 1/5/2016 and 2/3/2016 are entered in column A, I'd like the formula to fill in the dates from 1/1/2016 - 2/29/2016.
I know I can manually write in the dates and drag them down the column, but I have a lot of sheets, and using an Arrayformula will save me a lot of time. I've tried a similar formula in column B, but it doesn't autofill in the date gaps. Is what I'm looking for possible?
Here's a copy of the editable spreadsheet I'm referring to: https://docs.google.com/a/flyingfx.com/spreadsheets/d/1Ka3cZfeXlIKfNzXwNCOWV15o74Bqp-4zaj_twC3v1KA/edit?usp=sharing
Short answer
Cell A1
1/1/2016
Cell A2
=ArrayFormula(ADD(A1,row(INDIRECT("A1:A"&30))))
Explanation
In Google Sheets dates are serialized numbers where integers are days and fractions are hours, minutes and so on. Once to have this in mind, the next is to find a useful construct.
INDIRECT(reference_string,use_A1_notation) is used to calculate a range of the desired size by given the height as a hardcoded constant, in this case 30. You should not worry about circular references in this construct.
ROW(reference) returns an array of consecutive numbers.
A1 is the starting date.
ADD(value1,value2). It's the same as using +. As the first argument is a scalar value and second argument is an array of values, it returns an array of the same size of the second argument.
ArrayFormula(array_formula) displays the values returned by array_formula
As A1 is a date, by default the returned values will be formatted as date too.
Increment by Month
If anyone wants to be able to increment by month, here's a way I've been able to accomplish that. Your solution #ptim got me on the right track, thanks.
Formula
Placed in B1
First_Month = 2020-11-01 [named range]
=ARRAYFORMULA(
IF(
ROW(A:A) = 1,
"Date",
IF(
LEN(A:A),
EDATE( First_Month, ROW( A:A ) -2 ),
""
)
)
)
Result
ID Month
1 2020-11-01
2 2020-12-01
3 2021-01-01
4 2021-02-01
5 2021-03-01
I have an alternative to the above, which allows you to edit only the first row, then add protection (as I like to do with the entire first row where I use this approach for other formulas):
=ARRAYFORMULA(
IF(
ROW(A1:A) = 1,
"Date",
IF(
ROW(A1:A) = 2,
DATE(2020, 1, 1),
DATE(2020, 1, 1) + (ROW(A1:A) - 2)
)
)
)
// pseudo code!
const START_DATE = 2020-01-01
if (currentRow == 1)
print "Date"
else if (currentRow == 2)
print START_DATE
else
print START_DATE + (currentRow - 2)
Notes:
the initial date is hard-coded (ensure that the two instances match!)
ROW(A1:1) returns the current row number, so the first if statement evaluates as "if this is Row 1, then render Date"
"if this is row 2, render the hard-coded date"
(nB: adding an integer to a date adds a day)
"else increment the date in A2 by the (adjusted) number of rows" (the minus two accounts for the two rows handled by the first two ifs (A1 and A2). Eg: in row 3, we want to add 1 to the date in row 2, so current:3 - 2 = 1.
Here's a live example (I added conditional formatting to even months to assist sanity checking that the last day of month is correct):
https://docs.google.com/spreadsheets/d/1seS00_w6kTazSNtrxTrGzuqzDpeG1VtFCKpiT_5C8QI/view#gid=0
Also - I find the following VScode extension handy for syntax highlighting Google Sheets formulas: https://github.com/leonidasIIV/vsc_sheets_formula_extension
The Row1 header trick is courtesy of Randy via https://www.tillerhq.com/what-are-your-favorite-google-spreadsheet-party-tricks/
nice. thanks.
To get the list length to adapt to the number of days in the selected month simply replace the static 30 by eomonth(A1;0)-A1. This accommodates for months with 31 days, and for February which can have either 28 or 29 days.
=ArrayFormula(ADD(A1,row(INDIRECT("A1:A"&eomonth(A1;0)-A1))))
Updated for 2022:
This can now be done pretty easily with the SEQUENCE function, it's also a bit more adaptable.
Below will list all of the days in columns but you can swap the first 2 values to place in rows instead:
=SEQUENCE(1,7,today()-7,1)
More specific to your example, below will take the date entered (via cell, formula, or named cell) and give you the full month in columns:
=SEQUENCE(1,day(EOMONTH("2016-1-5",0)),EOMONTH("2016-1-5",-1)+1,1)