Google Sheets vlookup cannot find value error on date match - google-sheets

I have two sheets ('Car' and 'Gas Data') in a google sheets document.
Each has dates in column A. When I add a new date in a row in 'Car', a want to autofill the value in column D from the sheet 'Gas Data' with the matching date row.
My failing vlookup: =VLOOKUP(A2,'Ohio Gas Data'!A:D,4,FALSE)
I am getting the error: "Did not find value '44352' in VLOOKUP evaluation." but the value in A2 is a date and I have formatted both columns for dates.
How can I edit the above vlookup to select A2 in 'Car', match it with a date in column A of 'Gas Data', then select the value from Column D?

You may try with this. Even if it's a text or a date with time (meaning that instead of 44352 you have 44352.6012 for example), you can try with:
=XLOOKUP(DATEVALUE(A2),INDEX(DATEVALUE('Ohio Gas Data'!A:A)),'Ohio Gas Data'!D:D,"No match",0)
It should round or convert both the column and the value in A2 to make them match. I added an option of "No match" so you have the "feedback"
Let me know!

Related

Using a date in a cell in Sheet1 as a value for a filter in a Countifs formula for values in the date range on another sheet

I'm trying to use a formula in Google Sheets to use the date values of cells in Sheet1 (a27 and b27) as the Date references for the date range in the coutifs formula below.
=countifs('Sheet2'!$C:$C,">=01/10/2023", 'Sheet2'!$C:$C,"<=01/17/2023",'Sheet2'!$D:$D,"Apples")
This initial formula works fine, where I am trying to count how many instances of "apples" occurred in a specific date range on Sheet 2 (1/10/2023-1/17/2023).
As you can see, the dates on Sheet 2 are in column C, and the instance of "Apples" would be in column D.
However, I am trying to find a way to pull the data from Sheet2 to Sheet1 using date references in 2 cells in Sheet1. 'Sheet1'!a27 has the date value for 1/10/2023, and 'Sheet1'!b27 has the value for 1/17/2023.
I would like to be able to use the Sheet1 a27/b27 placeholders instead of manually going in and entering dates into the formula.
I have tried the string below, hoping it would pull the date values from Sheet1 a27&b27 automatically to be the date of reference for the countifs formula from Sheet2.
While it is not causing an "error", it is not pulling any numbers at all.
=countifs('Sheet2'!$C:$C,">='Sheet1'!a27", 'Sheet2'!$C:$C,"<='Sheet1'!b27",'Sheet2'!$D:$D,"Apples")
Please note that Sheet2 column C and Sheet1 columns b&c already have the number formats set to "date".
try:
=COUNTIFS(Sheet2!C:C, ">="&Sheet1!A27,
Sheet2!C:C, "<="&Sheet1!B27, Sheet2!D:D, "Apples")

Array Formula alternative solution with SumIF - Google Sheets

I have data in the below format:
The "Date" Column is a sequence of dates generated using the formula:
=sequence(datedif(TODAY(),MAX(D2:D),"D")+2,1,TODAY(),Date(0,1,0))
The "Avg. Mnthly Hrs" is calculated against each Date value as below:
=SUMIF(D:D,">="&E2,C:C)
The issue here is, whenever I have a new Project, where the "Exp. Project End Date" is let's say 5/31/2045, the Date column is extended automatically using the sequence formula and generates values in days until that day but the "Avg. Mnthly Hrs" formula doesn't calculate the new values (like in Array Formula).
The ArrayFormula doesn't work with SumIF formula. Is there any similar alternative so that the "Avg. Monthly Hrs" formula extends automatically for new values in Date column.
In F2, try
=arrayformula(if(E2:E="",,SUMIF(D:D,">="&E2:E,C:C)))

INDEX MATCH formula Google Sheet returns N/A value

I have 2 sheets in Google Sheet
https://docs.google.com/spreadsheets/d/1uqTUjoT978AyNU7TeBfVbcWDQ_aAamC7d51UB8gdLBk/edit?usp=sharing
I am trying to get "ranking" value from previous day ranking sheet.
Currently I am shucked with INDEX MATCH formula to get data from previous date sheet (20210810-0:7).
Please have a look at "20210811-0:6" sheet row 24, the formula I made returns N/A value
I tried VLOOKUP and combinations of INDEX MATCH formulas but all failed.
I checked the content D column with D column in another sheet, all values returned "TRUE"
Please tell me my mistakes. I tried many combinations of below formula.
=INDEX('20210810-0:7'!A4:A29,match(D24,'20210810-0:7'!A4:G29,0))
Yellow highlight is mistake formula
Green is how it should show.
=FILTER('20210810-0:7'!$A$4:$A$29,'20210810-0:7'!$D$4:$D$29 = D24)
Paste this in B24, I think this is what you are looking for.

Date comparison in query not matching when the cells being compared are date but works if cells are made into text

Sample sheet for reference: https://docs.google.com/spreadsheets/d/1P1XTAFzI1-M0zJZtKiBviSfohXcqbzaPEnxHlQ4zDSU/edit?usp=sharing
Im trying to compare one date cell to a column of date cells. I am using the query function to list out all the matching rows. Specifically I am comparing the date column in Call Log Details sheet to the date cell B2 in the EOD sheet. When I make both the column and cell in the 2 sheets to be formatted into mm/dd/yy, the function doesnt work. But when I make both the column and the cell in the 2 sheets to be formatted into Plain Text, the function works and displays the rows. I cant have the column in the Call Log Details to be Plain Text since I am adding a calendar and will be doing calculations using dates. How am I able to make the comparison to work with at least the column being a date value and if possible also the cell?
Here is the formula I am using to output the rows found in the EOD sheet at cell B2:
=query('Call Log Details'!A2:X," select T where A = '"&B1&"' order by A,B,D",0)
query understands dates only in this format:
yyyy-mm-dd
use:
=QUERY('Call Log Details'!A2:X,
"select T
where A = date '"&TEXT(B1, "yyyy-mm-dd")&"'
order by A,B,D", 0)
suggestion for column T:
={"RESERVED!!!"; ARRAYFORMULA(
{IF('Call Log Details'!E2:E="",,CHAR(10)&
"DATE : "&TEXT('Call Log Details'!A2:A+'Call Log Details'!B2:B, "m/d/yy h:m AM/PM")&CHAR(10)&
"PT: "&'Call Log Details'!D2:D&CHAR(10)&
"FROM: "&'Call Log Details'!E2:E&CHAR(10)&
"RELATION TO PATIENT: "&'Call Log Details'!F2:F&CHAR(10)&
"CALL BACK# "&'Call Log Details'!G2:G&CHAR(10)&CHAR(10)&
"MESSAGE.: "&CHAR(10)&'Call Log Details'!J2:J&CHAR(10))})}

Google Sheets =MONTH works but MONTH in QUERY does not

Google Sheets: I checked my column of dates is in DATE format not Automatic.
When I use MONTH in a cell I get the correct month back from that column.
When I do a QUERY such as =query('Main'!A1:M20,"select MONTH(M)",1) I get #VALUE! with the comment:
Unable to parse the Function QUERY for parameter 2: Can't perform the function MONTH on a column that is not a DATE or a DATETIME column
Why does QUERY not see the column as being in DATE format but =MONTH does?
months in a query are numbered and starts from 0, therefore, you will need to add +1 to get the first month and then do a weird logic: "where month1=month2" to get february (month(A)+1=3 for march, month(A)+1=12 for december, etc.)
=QUERY(A1:D10, "select A,B,C,D where month(A)+1=2", 1)

Resources