Function to organise a table - google-sheets

I have a table which I would like to make more dynamic based on values in two ranges.
I have a first table - DATE - (one column containing 1st January 2021 - 31st December 2022)
I have a second table - UUID - (one column containing the UUID)
Is there a way to display Each date individually for each UUID there is for each day like in the picture with a single formula?
Thanks alot!

try:
=INDEX(SPLIT(FLATTEN(FILTER(DST!A4:A, DST!A4:A<>"")&"×"&
TRANSPOSE(FILTER(MODTANEWBIE_PER!E3:E, MODTANEWBIE_PER!E3:E<>""))), "×"))
and for count:
=ARRAYFORMULA(IFNA(VLOOKUP(A4:A&B4:B,
{ATT_ARCHIVE!A4:A&ATT_ARCHIVE!B3, ATT_ARCHIVE!B4:B;
ATT_ARCHIVE!A4:A&ATT_ARCHIVE!C3, ATT_ARCHIVE!C4:C}, 2, 0)))

Related

Highlight Month Columns based on dates in Google Sheet

I would highlight, in Google Sheet, the columns of months based on dates in col AA:
dd/mm/yyyy (start date) - dd/mm/yyyy (end date).
Example:
Col AA ---> 25/05/2022 - 06/09/2022
The columns that must be highlighted: from May to September.
The best way is to change headers of column and put inside the first day of each month. Then apply a format as MMMM.
Conditionnal formatting formula:
=and(C$1>=EOMONTH($A2;-1)+1;C$1<=EOMONTH($B2;0))
if you can't change headers, the formula will be:
=and(MATCH(proper(text(index(split($AA2;" - ");1);"MMMM"));{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0)<=MATCH(B$1;{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0);MATCH(proper(text(iferror(index(split($AA2;" - ");2);"31/12/2022"*1);"MMMM"));{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0)>=MATCH(B$1;{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0))
You can try a much simpler formula:
=(EOMONTH(DATEVALUE("1/"&C$1);0)>$A2)*(DATEVALUE("1/"&C$1)<=$B2)
this works for current year.
If you want to use another year add it to string in DATEVALUE function, i.e. =DATEVALUE("1/"&C$1&"/2020")

SUMIF with VLOOKUP based on date range in multiple sheets

I have a sheet called "Orders" in which I add each order, its date and amount.
In a separate sheet, I have a monthly summary table.
I want a cell in the summary table to look at the "Orders" sheet, and if the date (in Orders, row G) falls between Jan 1 and Jan 31, I want the total from Orders, column AE to show in the summary table. I'll do this for each month.
This is what I have so far:
=SUMIF(VLOOKUP(AE4:AE5,'Orders'!G4:G5,">=1-Jan-2021″,G4:G5,”<=31-Jan-2021″),0)
Obviously that isn't right (I'm just playing around and don't really know what I'm doing!), but maybe I'm getting close.
Note that new rows (i.e., orders) will be added to the Orders sheet throughout the year, so I want AE5 and G5 in the formula to update automatically as I add a new row.
Any help much appreciated.
Here's one method, which requires a few more columns but isn't terrible. You could probably shorten this a little, but if you're in a pinch then it works.
In your orders sheet, add two more columns titled "Month" and "Year".
Month Formula (which extracts the numeric month from your date):
Cell C2: =MONTH(B2)
Year Formula (which extracts the numeric year from your date):
Cell D2: =YEAR(B2)
Then in your summary data, you create a SUMIFs formula. Picture below.
Cell K2: =SUMIFS(E:E,C:C,I2,D:D,J2)
If I've not misunderstood your requirement then sumifs (plural) itself can help out,
Conveniently you can have a named range "total" for the column G and "date" for column AE of the orders sheet
If you want to add dates greater than 1st of Dec and less than 5th of Dec then in the cell of the summary sheet you can add
SUMIFS(total,date,">=1/12/20",date,"<5/12/20")
I'm having some problems visualizing what your spreadsheet looks like, but assuming the dates you are checking against are in column G and your totals are in column AE, I think the following would work:
=SUMIFS(AE1:AE1000;G1:G1000;"<="&DATE(2020;1;31);G1:G1000;">="&DATE(2020;1;1))
If I wanted to make this formula to autoexpand as I added more rows to the table, I'd change my data into an actual table, and refer to the ranges by their headers. Or you can just do what I've done here, and set a range that is significantly larger than what you are likely to use and hope you never add any entries outside of it.
Okay, found it! The formula that has worked is
=SUMIFS(Orders!$AE4:$AE5,Orders!$G4:$G5,">=1/1/21",Orders!$G4:$G5,"<=1/31/21")
Thanks for all your help!

COUNTIFS Date contains this month - Google Sheets

Column A contains Datevalues.
Column B a String.
I would like to count all cells where A is this month and B contains a certain String.
Here is my approach: =COUNTIFS(B1:B; "Certain String"; MONTH(A1:A); MONTH(TODAY()))
Unfortunately this approach does not work. Any idea?
=COUNTIFS(B:B;"Certain String";A:A;">"&eomonth(Today();-1);A:A;"<="&eomonth(Today();0))
Does not count this month in other than this year.
=ARRAYFORMULA(COUNTIFS(B:B, "string", MONTH(A:A), "="&MONTH(TODAY())))

How to autofill dates using arrayformula

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)

Return Row when criteria from two columns is correct

Google Sheets: I need to return a row based on searches in two columns (each column has repeating data). Column A has a list of dates with duplicate dates. Column B has a list of names with repeating data. I need to return the row when I get a match from the date and name. This row is returning to another sheet in the same sheets document.
Please try:
=query(Sheet1!A:C,"select * where A=date '2015-01-01' and B='A' ")
where the date of interest is taken as Jan 1, 2015 the name of interest A and the assumption made that in addition to ColumnsA:B data you also want the corresponding ColumnC values.

Resources