A year has 4 quarters. If I choose a quarter, I would like to get a list of the Week Numbers for that quarter.
I know I can use WEEKNUM to get the week number of a date (and optional parameter to indicate Week begins on a Monday).
My goal is to use that as a list in a Data Validation dropdown element. If I can output the range in cells I can easily use that for reference.
In short I need to be able to create a range of numbers between two values.
For example; if given these two numbers, 12 and 24:
How could I populate a range of cells with 12, 13, 14, 15, and so on, through to 24.
use this:
=SEQUENCE(1; 13; 12)
Nevermind. I figured it out:
=TRANSPOSE(ARRAYFORMULA(Row(12:24)))
Related
I have a table listing name, date, order quantities. I need to compare the quantity between two dates.
I am trying to extract and calculate amount of difference by certain date range in automatically (eg: from Day-2 to Day-1).
For example in this following dataset:
Supposed Today is 3/10/2022 so Day-1 is 2/10/2022 and Day-2 is 1/10/2022
In D-1, Product A has 15 orders, D-2 has 10 order => difference between two dates is 5.
This formula "=INDEX($B3:$F3,MATCH(DATE(2022,10,3),$B$2:$F$2,0)-2)-INDEX($B3:$F3,MATCH(DATE(2022,10,3),$B$2:$F$2,0)-1) " works well with case above.
However, I also want to use this for calculate in bigger time range (for example a week and a month. I change this code to =INDEX($B3:$F3,MATCH(DATE(2022,10,3),$B$2:$F$2,0)-8)-INDEX($B3:$F3,MATCH(DATE(2022,10,3),$B$2:$F$2,0)-1) => the output shows: Function INDEX parameter 3 value -3 is out of range. Anyone have any suggestions?
enter image description here
try in G3:
=INDEX(C3:C5-B3:B5)
I have 2 columns one with letters A,B,C and other one with number 1,2,3. If I want to only see those letters whose corresponding numbers are less than 3, I would =filter(O39:O41,P39:P41<3). It works.
If I change second column to dates, this breaks. =filter(O39:O41,P39:P41<1/3) tells me No matches are found in FILTER evaluation.
Please help :)
You can wrap it up in date or use something relative to date like =filter(range, date_range< TODAY(), date_range> TODAY()-50)
I need to write a formula that enters 'Y' if the patient is up to date with their immunizations based on their record and age, and 'N' if they are not. Age (D$) is in months and I have a column for every immunization (8 weeks(E$), 12 weeks(F$), 16 weeks(G$), 1 year(H$), 3 years and 4 months(I$)) which is marked as either ("Y" or colored Grey) as well as a final column which the formula is being entered into(J$). Any ideas what formula I need to use?
So far I have been thinking to use an IFS statement { =IFS(D$>=2, AND(E$="Y"),"Y")}. Although I can see the limitations to using this.
For every immunization, the patient is not up to date if the corresponding cell is blank and their age is older than the immunization date. You want to check this for multiple immunizations. You can use COUNTIFS to evaluate two (or more) conditions.
=IF(COUNTIFS(E3:I3,"",E$1:I$1,"<="&D3)>0,"N","Y")
Explanation:
COUNTIFS returns the number of shots for which the patient is not up to date.
IF returns N if the previous value is greater than 0, Y otherwise.
Note that I'm assuming the information on the number of months corresponding to each immunization (E$1:I$1 in the formula above) is present somewhere in the sheet or that you can add it. If this is not the case, you would indeed need to use IFS or something similar.
I have a sheet with this table as an example:
What I want to do is a formula that displays the lowest value from today until the last day.
Example: If today is the first day, the lowest value (column "Current") until the end of the table is $50 (day 2).
But if today is day 3, for example, I want the cell to display the lowest value from day 3 until the last day, in this case, it would show value $450 at day 4, ignoring all the previous values before day 3.
Is this possible?
D4:
=MIN(C4:$C$10)
Drag fill down
I could find in a forum how to use matrix to calculate:
{=MIN(IF(days>=DAY(TODAY());values))}
Where days and values are named ranges.
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)