How do I insert cells by dates? - google-sheets

I want to extract company name and its contract price and cost only from 2-14jan 2022? How can i do that?
Thank you

Here's a sample setup with raw data in Columns A-E
Cells H1, H2 has the date inputs which you can manipulate accordingly.
formula:
=FILTER(C:E,B:B>=H1,B:B<=H2)
alternate formula:
=QUERY(A2:E,"SELECT C,D,E WHERE B>=DATE '"&TEXT(H1,"yyyy-mm-dd")&"' AND B<=DATE '"&TEXT(H2,"yyyy-mm-dd")&"' ")
NOTE: the above formula(s) are bound to throw error incase the date in your second column is not a proper date format and rather a text date

Related

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))})}

Convert string date from UTC to AEST

I'm importing submissions from a DUDA contact form into google sheets but the time stamp is coming across as a string in the wrong time zone (2020-11-16 23:26:29 UTC). As I can't change the form settings to convert the time zone automatically, is there a formula that I can use to do this every time a new submission is saved to the spreadsheet?
It's not clear from your post where (i.e., in which sheet or column) your incoming data is. However, it is best practice never to add anything to a form-intake sheet. Rather, you should do manipulations in another sheet (even if you wind up hiding that sheet from view afterward), and then reference that conversion sheet elsewhere.
That said, supposing that your form-intake sheet is named "Form Reponses 1" and that your UTC dates are coming in as text into A2:A, you can try this formula in cell 1 of an otherwise empty column in another sheet:
=ArrayFormula({"Header"; IF('Form Reponses 1'!A2:A="",, DATEVALUE(REGEXEXTRACT('Form Reponses 1'!A2:A,"^(.+) ")) + TIMEVALUE(REGEXEXTRACT('Form Reponses 1'!A2:A," (.+) ")) + (10/24) )})
You can replace "Header" with a more meaningful header.
The results will likely come across as numbers in the 40,000 range with an extended decimal amount. This is the raw date/time format. Just set Format > Number for the column to whatever data/time format you prefer.

Combining date/time and maintaining number formatting

I am using an array formula and IMPORTRANGE to import and combine a date column and time column from another sheet:
=ARRAYFORMULA(IMPORTRANGE(BG1, "FORM-SORT!V:V") & CHAR(10) & (IMPORTRANGE(BG1, "FORM-SORT!W:W")))
The first range is my date column and the second is my time column. The data is importing and combining properly, however neither the date nor time is formatting correctly, they are displaying integer values and will not respond to any number formatting options.
Please try:
=ARRAYFORMULA(text(IMPORTRANGE(BG1,"FORM-SORT!V:V"),"dd-mm-yy")&CHAR(10)&TEXT(IMPORTRANGE(BG1,"FORM-SORT!W:W"),"hh:mm"))

Returns the number of unique values in data studio when date matters

I have my dataset in Google spreadsheet and I wish to know the unique number of customers in a specific date range:
Let's say this is my data set
Customer Date
A 22/07/2017
B 24/07/2017
A 23/07/2017
I use this formula COUNT_DISTINCT(Customer) however because row 3 have different date from row 1 the output is 3 (however, I wish to have 2 as my output)
If you want to know the number of unique values in column A regardless of the date then would this formula work:
=COUNTUNIQUE(A2:A)
Or is you want to combine this with a specific date range then:
=COUNTUNIQUE(FILTER(A2:A,B2:B>=datefrom,B2:B<=dateto))
In this formula, datefrom and dateto can be either a value or a cell reference

QUERY using cell contents as SQL variables

Here is what the spreadsheet I'm working with looks like:
Summary table
(top of sheet)
Source data
(same sheet, below output)
I'm using the QUERY function to populate the appropriate feeds in the summary table with the data starting at A24 needs to be placed into.
Here is the formula I'm using in cell C6 (similar formulas are used throughout the summary table):
=QUERY($A$24:$D$57, "Select D Where B='ENQ' and A='2/27/14 - Thu'")
This gets the right information, but the formula needs to be edited to be unique in each cell it's used in. The problem being unable to quickly populate the cells with A='2/27/14 - Thu' being too specific.
I was trying to set it up so that:
date in A would compare with dates found on headers in ROW 2 before accepting data
room type in B would compare with value from A in each row of the summary table
How can the QUERY function be written to refer to these values as variables, instead of using the literal strings in my original function?
Instead of fixed strings such as 'ENQ', you can have your formula refer to the index in column A of your output. For example, you could change your formula to this, in cell C4:
=QUERY($A$24:$D, "Select D Where B='" & $A4 & "' and A='2/27/14 - Thu'")
^^^^^^^
The ampersand (&) is used to concatenate string segments.
Note that since the source data extends to the bottom of the data range of the sheet, we can forego specifying the bottom row. The range $A$24:$D will take in all rows, so it will automatically adjust to additional source data.
To compare dates, both values need to be dates. "2/27/14 - Thu" is not recognized as a date in your source data sheet, but as text, even though you've set the numeric format to date. So make sure you change all your source data to have actual dates in column A.
You can still have your dates formatted the way you like - see this screenshot. The content of A2 is now a proper date, "2/27/2014", but the format is set to display "mm/dd/yy - DDD". As long as the data is a date, the query can be built using the spreadsheet TEXT function to interpret the date in its yyyy-mm-dd format.
With dates in your source column, you can use todate() scalar function to tell QUERY to convert the date in the source to a query-date, and the date keyword to treat the following literal string (from C2) as a date.
The resulting function for cell C4 is:
=QUERY($A$24:$D , "Select D Where B='" & $A4 & "'and todate(A) = date '" & TEXT($C$2,"yyyy-MM-dd") & "'")
^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Similarly, for D4:
=QUERY($A$24:$D , "Select C Where B='"&$A4&"'and todate(A) = date '"&TEXT($C$2,"yyyy-MM-dd")&"'")
Your calculations in column E can be improved to handle #N/A results appearing in columns C or D:
=if(isna(C12*D12),0,C12*D12)

Resources