I have a large set of data that's updated every 2 weeks, so I'm looking to simplify the solution.
Imported sheet has data from D6:G. The date is in Column B.
Right now, I insert column H and use
=ARRAYFORMULA(if(isblank(B6:B),"",datevalue(B6:B)))
In a new sheet, I import the data and order by Col H (the converted date) and Col G (the employee's name).
=query(TimeApr10!B6:H,"select B,C,D,E,F,G where H is not null order by H,G asc")
Is there a way to combine the two steps by converting Col B in the query to datevalue? If I don't convert the date, the ordering doesn't work.
Related
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.
Does anyone know how I can add to the below query to find results between 2 time periods and sort from earliest to oldest.
'"&B5&"' in the query = MONDAY.
P in TempCSV is time from splitting date & time in column D with this formula in column O =iferror(split(D2, " ")) and this continues down the column for all other rows.
I cant use date and time from D as the date is creation date and not current date in relation to what I'm trying to achieve.
=query(TempCSV,"Select A,D where A contains 'Something' and A contains 'Anotherthing' and C contains '"&B5&"' **where P >=05:00:00 and P <=12:00:00**")
I have successfully got the following to work in another range but this is due to the date and time being correctly recorded in the same cell.
=query(TPM,"SELECT A,B,C where A contains 'Something' and A contains 'Anotherthing' and C >= datetime '"&text($C$5,"yyyy-mm-dd 05:00:00")&"' and C < datetime '"&text($C$5,"yyyy-mm-dd 12:00:00") & "'")
I need to calculate a column in google spreadsheet.
Column B is a price column (priceUSD). I want to be able to calculate if the price the following day is 5 % higher or more, then it should return a 1.
Otherwise a 0 (if price is less than 5% higher the following day)
I do not want to add more columns for this only using column D
(column A is a date column)
A B C D
date priceUSD Addres Over5
=if(B1*1,05>B2) then return 1
Maybe, in D3, something like:
=ArrayFormula(1*(B2:B900*1,05<B3:B900))
I would like to ask if anyone knows the exact syntax to get this query working on google sheets.
I currently have 3 Sheets:
1. Sheet A, RAW DATA (where all my Raw Data is)
2. Sheet B, Main Page (where I have my user input on the date)
3. Sheet C, Filtered Data (where I would like to use the Query to pull out filtered data from Sheet A)
So I have set up a generic query goes like this in Sheet C, it works:
=QUERY('RAW DATA'!A:J, "SELECT * WHERE F > date '2018-03-20' AND F < date '2018-03-22' AND F IS NOT NULL ORDER BY F",1)
I would now like to replace the 2 dates, with user input dates, which are B5 and D5 in Sheet B.
I have tried this syntax:
=QUERY('RAW DATA'!A:J, "SELECT * WHERE F > date '"&Main Page!B5&"' AND F < date '"&Main Page!D5&"' AND F IS NOT NULL ORDER BY F",1)
Do note that B5 and D5 have already been set up with data validation rules to ensure that only date values are allowed.
Could anyone point out my mistake?
Thank you!
The date provided to QUERY must be:
a string of
format yyyy-mm-dd
Try changing from
date '"&Main Page!D5&"'
to
date '"&TEXT(Main Page!D5,"yyyy-mm-dd")&"'
I am trying to write a formula that would pull data based on a selection I made and within the date range I put in as well. The code I wrote below does not work. What am I writing incorrectly?!
=QUERY(INDIRECT(CONCATENATE(A2,"!A:FB")), "where (C >=date '"&TEXT('Feedback Report'!C3,"yyyy-mm-dd")&"' and C <= date '"&TEXT('Feedback Report'!D3,"yyyy-mm-dd")&"' and E contains '"&B2&"' ",1)
I asked too soon. After trying one more time, I have found a solution:
=QUERY(INDIRECT(CONCATENATE(A2,"!A:FB")), "Select * where (C >=date '"&TEXT('Feedback Report'!C3,"yyyy-mm-dd")&"' and C <= date '"&TEXT('Feedback Report'!D3,"yyyy-mm-dd")&"' and E contains'"&B2&"')")
Here is the breakdown:
Formula is on a sheet that pulls data from another source (raw data)
INDIRECT(CONCATENATE(A2,"!A:FB")) is where the data is stored
A2 is the sheet I choose from a drop down menu to have the data be pulled from
C is the date column of the raw data
C3 is the starting query date
D3 is the ending query date
E is the category column
B2 is the category value I want to search on
Hope this helps people in the future.