I am having trouble to find the right formula to import dates from news websites into Google Sheet.
We have more than 300 website to retrieve the date from it, so I can't do it one by one.
I tried these formulas (the F column is my URL)
=IMPORTXML(F2;"//#class=pubdate")
=IMPORTXML(F3;"//date")
And then I saw this questions, but cannot understand where I fail to achieve what I want:
Can't figure out how to get time attribute
And it says I have to use this formula:
=REGEXEXTRACT(QUERY(transpose(QUERY(importdata(F4),,1E+100)),,1E+100),"datetime=""(.*?)""")
So in the end, what I would like is:
[Column A : Title; B : text; C : Image; D : Tag ; F : URL; G : Date the publication was published][1]
Related
I have two google sheets in the same workbook and I am trying to import certain columns from one into the other sheet based on what hour of class was chosen. For example, I have the Date in column A, Name in B, Email in C, and Number in D and other stuff, then the Class in I.
Column A - Date
Column B - Name
Column C - Email
Column D - Number
...
Column I - Class
My goal is to import column B through D if column I has a certain class. I tried a using this if statemnt: =if('Confirmação'!I2 = A1,(=importrange("sheet_url","Confirmação!B2:D2")), "NOPE")
where A1 has the name of the class to look for, but it resulted in a #Error.
Then I tried a variety of query such as the following:
=QUERY({'Confirmação'!B2:D2,'Confirmação'!I2},"Where I = 'Terça 19h English 1'")
=QUERY({'Confirmação'!B2:D2, 'Confirmação'!I2},"Where 'Confirmação'!I = 'Terça 19h English 1'")
and also added the IfError: =iferror(QUERY('Confirmação'!B4:I4,"Where I = 'Terça 19h English 1'"),"Vaga")
Could someone correct my functions or help with a google script? Thank you! Very much appreciated! (Sorry about the Portugues-it's a project I am working on in Brazil)
In case you still want to do it using QUERY:
Using your formula with slight modification:
=QUERY({'Confirmação'!B2:D2,'Confirmação'!I2},"select * where Col3 = 'Terça 19h English 1'").
In case you want the formula to take the class name dynamically, then you can modify the formula to =QUERY({'Confirmação'!B2:D2,'Confirmação'!I2},"select * where Col3 = '"&A1&"'") where A1 is the cell with the class name.
Instead of using a QUERY, you can use the =FILTER() function to solve your problem. Doing the following:
=FILTER('OriginSheet'!B:D;'OriginSheet'!I:I = 'Certain Class')
Then you can still add more conditions:
=FILTER('OriginSheet'!B:D;'OriginSheet'!I:I = 'Class 1';'OriginSheet'!I:I = 'Class 2';'OriginSheet'!I:I = 'Class 3')
Try that and let me know if it worked.
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")&"'
This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 5 months ago.
I need to compare a text column, which contains a string that represents a date in the format dd/mm/yyyy, to another date.
The range is in another sheet. I cannot edit it to format the column to a date field:
I need something like this:
=query(importrange(...); "select A, B WHERE C >= '2017-01-08'")
Of course this doesn't work because only Aldo row will be visible. Is there any way to convert, in the query function, the column C to a date or to a string with the pattern yyyy-mm-dd to compare it to the right hand side value of the comparison?
Cumbersome but seems to work:
Import (say to Sheet1!A1):
=importrange(" k e y ","Sheet1!A:C")
Add a column with recognisable date formats (say in D1):
=ArrayFormula(datevalue(C1:C))
then apply the query:
=query(Sheet1!A:D,"select A,B,C where D >= date '2017-01-08' ")
I know this is WAY late, but I ran into this same problem a couple of years ago and fixed it by doing the following:
Cell A1 contains: 2/21/2018
Cell A2 contains: =DATEVALUE(B1)
which results in 43152 and I copy into the QUERY statement:
Cell A5 formula: =QUERY(Sheet!Range, "select B, C, E where B=43152")
But, to make it somewhat better by only having to type in the date, I used the CONCATENATE function to create the text "select B, C, E where B=43152" in a cell and then referenced that cell in my QUERY, like so:
Cell B1: =CONCATENATE("select B, C, E where B=", A2)
Cell A5 formula: =QUERY(Sheet!Range, B1)
This works well for me and I hope it helps someone else or at least gives someone an idea.
This is the formula I'm currently trying to use, however it only results in 0's.
=ARRAY_CONSTRAIN(ARRAYFORMULA(SUM((Log!$G$3:$G$1000 = "W") * ((Log!$J$3:$J$1000 = B2 & Log!$B$3:$B$1000 = A2)))),1 ,1)
Log!$G$3:$G$1000 = Cells that are marked as W (for wins) and L (for losses).
Log!$J$3:$J$1000 & B2 = Which year the match was in.
Log!$B$3:$B$1000 & A2 = The sport.
If I remove the & Log!$B$3:$B$1000 = A2, the formula works just fine, but it's showing every result for every sport from every year, which isn't what I want.
I'm trying to get it to show only the wins from a specific sport for a specified year, but I can't get any formula to work.
Any idea?
Edit: I should have noted, this is for google's spreadsheets.
I would suggest using the filter function:
=FILTER(Log!A-Z,Log!G:G="W",Log!J:J=$B$2,Log!B:B=$A$2)
note I guessed at the first array for A-Z so you should modify to reflect the actual range your trying to pull in. Also there are always slight difference, so if it needs to be modified a bit, then please share a sheet with some dummy data
I hope someone can help me; I am building some spreadsheets to help with time-tracking. I have a list of tasks, with columns for criteria including date, hours spent, category of work, and client.
I want to filter this data by month, so for example I would like to know how long I spent in a single month on correspondence. This means I need to select all the rows where category = 'correspondence' and where the dates are all from one specified month. At the moment, I am having to use a query which outputs to an intermediary table, and then run a filter function on that table in order to output to my final table. Here are my two functions:
=QUERY( 'Task List'!A4:F , "select A, B, E, F where C = 'Correspondence'" )
that gives me the first table, with just the rows where the category is "Correspondence". Then, on that table, I have to run the next function:
=filter(J4:M,J4:J>=date(2015,4,1),J4:J<=date(2015,4,31))
To get only the rows from this month of April. If possible I would like to remove the intermediary table (which serves no other purpose and just clutters my sheet).
Is it possible to combine these statements and do the process in one step?
Thanks.
That is indeed possible.
Since you didn't specify in which column the dates are to be found (in the 'raw' data), I assumed for this example that dates are in col F. The easiest way would be to use the MONTH() function. However, when used in query(), this function considers January as month 0. That's why I added the +1. See if this works ?
=QUERY( 'Task List'!A4:F , "select A, B, E, F where C = 'Correspondence' and month(F)+1 =4 ")
I came to this question needing to filter by weeknum() and year() as well as query by contains(). It can be helpful to combine the query and filter functions for similar but more dynamic date and text matching needs. If for example the OP had needed to show this data by week, that is not available in the Google Query Language.
The filter function does not have the contains function so you are limited to exact match text or using Reg-Ex. The Query Lanuague does not have the Weeknum functions.
Combining Filter and Query can be useful in scenario similar to this question but with a dynamic timeline (no hard set month or date such as rolling timeline) and where the text your matching is not exact (when you need to use a contains function from query language).
Here is an example for combining filter and query in Google sheets.
=(sum(Filter(QUERY(FB!$A:$Z, "select Q where B contains 'Apple'"), Weeknum (QUERY(FB!$A:$Z, "select E where B contains 'Apple'")) = Weeknum($A8))))
In this example I queried Facebook ads data export for any posts which contained the word 'Apple' in their title, and where Weeknum() matched the ongoing weeks on my sheet, in order to pull weekly data from multiple sources into one table to build reports, with minimal updating required as the timeline runs on.
It selects Q(spend) Where B(title) contains Apple, and Weeknum(E) matches week number on current row of sheet(A8). I have found this useful many times. Query + Filter Example Sheet Here.
If OP wanted to pull this info dynamically as the months went on if A column contained months in order the formula could be pulled along and would automatically pull data from query data filtered by matching month month.
=(sum(Filter(QUERY( 'Task List'!A:Z , "select A, B, E, F, J where C contains 'Correspondence'" ), Month(QUERY( 'Task List'!A4:F , "select J where C contains 'Correspondence'" )) = Month('$A2'))))