Sheets: Index & Match string, search Column, + Countif dates in the future - google-sheets

I am using google sheets, and trying to create a small table that shows me how many events for a single location (city) are currently on sale.
The method I'm using, is trying to search for a string in cell reference "A3" in sheet2 row 2, then count the date values in that column that are in the future.
What I thought would work this way was;
=COUNTIFS(INDEX(MATCH($A3,TestMes!$A2:2,0),TestMes!5:100,0)), ">"&TODAY()
I have included an example here that anyone is welcome to edit;
https://docs.google.com/spreadsheets/d/1a2rqWaYNzb2xphnv1RZOoEsKoYBRhJHdJTmIp9EGiSY/edit?usp=sharing
Where;
COUNTIFS counts the number of cells in the range which are greater than today (ie; future)
INDEX is the range of the column where;
MATCH has searched the second row in the second sheet to identify which column to index, then Counts all the dates within that column that are also within the range 5:100,
and finally outputs a count of the current live dates.
I'm getting a formula parse error, have watched 3 20 minute youtube videos, and tried all manner of combinations, im totally stumped.
Am I overcomplicating the formula?

Added formula(s) to your sheet:
=COUNTIF(IFNA(FILTER(Sheet2!$5:$100,Sheet2!$A$2:$2=$A3)),">"&TODAY())
=BYROW(A3:A,LAMBDA(z,IF(z="",,COUNTIF(IFNA(FILTER(Sheet2!5:100,Sheet2!A2:2=z)),">"&TODAY()))))

Related

Google Sheets: Query Function - Counting unique values, but failing to show zeros

I am trying to create a function that allows me to count how many times a column has a certain phrase (i used dropdown menus in the column) and then sorting it by the month. However, if there is a month that doesn't have any of the items I am searching it doesn't populate a row in the query table showing that month had zero of the burgers, etc. Does anyone know how to have the query function show the 0 for months that did not have results.
=QUERY('2022'!A1:Z,
"select count(E)
where E= 'Burgers' and B >=date """&text(D2,"yyyy-MM-dd")&""" and B<=date """&text(D3,"yyyy-MM-dd")&"""
group by B
Label count(E) 'Burgers'")
Use the following formula in a single cell.
={INDEX(TEXT(DATE(YEAR(D3),SEQUENCE(MONTH(D3)-MONTH(D2)+1),1),"mmmm yyyy")),
INDEX(MAP(DATE(YEAR(D3),SEQUENCE(MONTH(D3)-MONTH(D2)+1),1),LAMBDA(x,COUNTIFS(Data!D2:D,"Burgers",Data!A2:A,">="&x,Data!A2:A,"<="&EOMONTH(x,0))))),
INDEX(MAP(DATE(YEAR(D3),SEQUENCE(MONTH(D3)-MONTH(D2)+1),1),LAMBDA(x,COUNTIFS(Data!D2:D,"Drinks",Data!A2:A,">="&x,Data!A2:A,"<="&EOMONTH(x,0)))))}

In Google Sheets, I want to populate cells in Column A with certain conditions, based on the contents of column B

In this sheet,
https://docs.google.com/spreadsheets/d/1MR0n1FoutASbuwiNJS7FrcQhxHF6Bo03oVs9RZPo9g4/edit?usp=sharing
I am trying to have column B be populated with cell values equal to is today's date or tomorrow's date, by referencing column F.
Then, I am trying to have column A be populated with the contents of column E, based on if the column E's item is for today or tomorrow (Basically if the item's corresponding date shows up in B).
I've tried playing with index, lookup and filter but I cannot manage to get the formula right, and when using index and lookup there are many empty cells in between the dates.
I would appreciate any help.
I added a sheet ("Erik Help") with the following formula in A1:
=ArrayFormula(IFERROR(FILTER(E:F,(F:F=TODAY())+(F:F=TODAY()+1))))
That one formula returns all results you wanted to see.
Explanation:
The key part to understand is the condition that FILTER is using to filter in entries; and that is (...) + (...). The plus sign is the equivalent of OR in an array. So it's basically saying, "Filter in all results from E:F where (F:F = today) OR (F:F = tomorrow)." And if there is no match at all found for that OR condition, IFERROR will just return nothing (rather than an error).
Reference:
FILTER

In Google Sheets, how to check if Cell A (Date) is within the Date range of Cell B and C

I have a sheet with a timeline that shows a month per row in column A and an amount in USD next to that month in column B.
I want to be able to specify amounts in column G with a start and end date for that amount in columns E and F.
What I am trying to achieve is that the values in column B are automatically calculated by looking at the start and end dates specified in columns E and F and then taking the corresponding value from column G if the date in column A falls in between the date range specified in E and F.
I have found many suggestions for similar problems online but wasn't able to get any of them to work for my specific case. Any help is very welcome
You could do it as an array formula like this:
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("`E3:E"&count(E3:E)+2)),"YYMM"))*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))*transpose(indirect("G3:G"&count(G3:G)+2)),(INDIRECT("G3:G"&count(G3:G)+2)+2)^0))
The idea is to develop a 2D array where the rows are the months and the columns are the amounts for matching time periods. Then use the standard Mmult method to get the row totals of the array.
Using indirect for the ranges makes the formula longer but using full-column references would be slow as it would result in a nearly 1000 X 1000 array for a default-sized sheet.
EDIT 1
Or shorter
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("E3:E"&count(E3:E)+2)),"YYMM"))
*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))
,INDIRECT("G3:G"&count(G3:G)+2)))
because you can combine the row totals step with multiplication by column G.
EDIT 2
Alternatively you could just employ a much simpler pull-down formula using SUMIFS:
=ArrayFormula(sumifs(G$3:G,eomonth(E$3:E,-1)+1,"<="&A2,F$3:F,">="&A2))
This uses Eomonth to change all the start dates to the first of the month so they can be compared to the dates in column A correctly. The formula still has to be entered as an array formula because of the Eomonth calculation.
Note
The equivalent pull-down formula to the original array formulas above would be
=ArrayFormula(sumifs(G$3:G,text(E$3:E,"YYMM"),"<="&text(A2,"YYMM"),text(F$3:F,"YYMM"),">="&text(A2,"YYMM")))
but this gives zero for all rows - the reason for this is not obvious to me at time of writing.

Arrayformula not working with index and match google sheets formula

I have data in three columns. Column A contains a list of fruits. The second column the rank (1,2,3...) and the third column a list again but this time ordered by preference.
I want to return the rank in the fourth column. I have tried this formula which works as it should but it's returning just one value yet it's an array formula. What could be missing?
=ARRAYFORMULA(index(B2:B11,match(A2:A,C2:C11,0)))
Link to my spreadsheet.
https://docs.google.com/spreadsheets/d/1e7xCcdPa3MywDVs70o2kXAwMnzJRMDuucktWPowS_MY/edit?usp=sharing
Index doesn't work with array formulas so you have to use Vlookup instead:
=ArrayFormula(if(C2:C="","",vlookup(C2:C,A2:B,2,false)))

Google query function

I am trying to return multiple records from a logbook into a final monthly statement... I'm using the query function but I do not get multiple records, it only displays the first match.
My sheets are from 1-31 for days of the month, then the last sheet labeled 717 is for Unit #717's monthly statement.
On Sheet 717, I would like to display information from sheets 1 through 31. Where column A=717, display values from columns B,C,D. Currently, it will only show me the first match. The amount column should show the corresponding rate for that row.
I hope my explanation is not confusing, any help is much appreciated. Thanks.
Here is a link to sample spreadsheet.
As you are concatenating the output of QUERY functions, you are actually performing an "array calculation", and you'll need use an "array calculation enabler", otherwise you will indeed only get the first applicable result.
=ArrayFormula(QUERY('1'!A3:G60;"select B where A=717")&QUERY('1'!A3:G60;"select C where A=717")&QUERY('1'!A3:G60;"select D where A=717"))

Resources