GoogleSheet Formula to Bring Back GoogleNews - google-sheets

Looking for a GoogleSheet formula that will bring back
UNIQUE HEADLINES, off GoogleNews specifically by keyword "Tesla"
with Publication Date sorted by ASC
Limit 20 headlines
Then, I want to group headlines by dates.
Thanks in advance!

You can use the =IMPORTFEED() function in Google sheets, and use sort and unique to make sure that you do not have duplicate titles and that they are sorted by date.
First, you need to construct the Feed URL of Google News using this format:
https://news.google.com/rss/search?q=<KEYWORD>
For this case, I used:
https://news.google.com/rss/search?q=Tesla
After that you need to construct the formula:
=IMPORTFEED("https://news.google.com/rss/search?q=Tesla")
Note: By default, you will get the first 20, so the basic =Importfeed() formula will work
To sort the information, since the format of the date is odd, it cannot be sort directly. So I use this formula in the E1 cell:
=INDEX(IF(C1:C20="",,REGEXREPLACE(C1:C20," GMT","")*1))
Lastly, I create a new sheet (name the last one "raw") to sort the date on this one:
=SORT(raw!A1:E20,5,true)
It will look like this:
Reference:
ImportFeed fuction.
Sort Function.
Unique Fuction.

Related

SUMIFS and ARRAYFORMULA within Google Sheets

I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)

When using SUMIF function, is there a way to accept timestamp values (e.g. 2/12/2019 19:56:16) as the range to test against the criteria?

I'm working with two columns,
column A: a list of timestamps
column B: a list of numbers
I'm trying to use the sumif(range, criteria, [sum range]) function to check if the month in column A is January, and so on for all months.
The issue is that I need a way to either convert the range for the sumif to month names, or use criteria other than a string (because a timestamp isn't going to ever be "=January".
My thought was that I could do either
=sumif(TEXT(TO_DATE(A2:A),"mmmm"), "=January", B2:B)
or
=sumif(A2:A, TEXT(TO_DATE(A2:A),"mmmm")="January", B2:B)
these are more or less pseudo-code, I'm trying to convey my thought process
I understand I could create a new column that converts the timestamps into months, but is there anyway I can preform this sumif, without having to make a new column?
Using SUMIFS, with dates you set the extents, this works in excel and google sheets:
=SUMIFS(B:B,A:A,">=" & DATE(2019,1,1),A:A,"<" & DATE(2019,2,1))
With Google Sheets you can also use filter:
=SUM(FILTER(B:B,MONTH(A:A)=1))
"=2" = February, "=3" = March, etc.
=ARRAYFORMULA(SUMIF(MONTH(A2:A), "=2", B2:B))
if you want to select it from a drop-down menu use:
=ARRAYFORMULA(SUMIF(MONTH(A2:A), "="&MONTH(F2&1), B2:B))

Google Sheet, Finance: FILTER twice to get only one cell

I have a Google Sheet with some stock information.
I'm using the formula GOOGLEFINANCE($B2, "price",TODAY()-15) to retrieve historical information about a stock (symbol named in $B2).
That returns a 2x2 table:
Date Close
8/25/2017 17:36:00 7.46
I only want the 7.46:
Using =FILTER(GOOGLEFINANCE($B2, "price",TODAY()-15),{FALSE; TRUE}) I get:
8/25/2017 17:36:00 7.46
I can't see to be able to nest FILTER twice.
I checked the documentation. Other than say that I should not use FILTER to filter columns and rows in the same call, I didn't get much out of it.
I gather a lot of stock information and always use index to get the stock price.
=index(GOOGLEFINANCE($B2, "price",TODAY()-15),2,2)
If you want the date use this. Be sure to format the cell as date or date/time.
=index(GOOGLEFINANCE($B2, "price",TODAY()-15),2,1)
For 2 filters try:
=FILTER(FILTER(GOOGLEFINANCE($B2, "price",TODAY()-15),{false;true}),{false,true})
I prefer query in this case:
=QUERY(GOOGLEFINANCE($B2, "price",TODAY()-15),"select Col2 label Col2 ''")
Also please try this formulas separately:
={false;true}
={false,true}
and see the result.

How do I import data from another sheet and then filter it based on 2 different variables?

I have been working on how I budget and keep track of my finances. In the process, I put together this Google Sheet which I am happy to share a dummy version of (includes dummy data).
I use a Google Form to input new entries which are recorded in the 'Log' page.
From here, I use a few SUMIFS to pull in the totals of any given income/expense category based on the category name (referenced in the cell adjacent), the month (B3), and the year (C3).
What I now want to do is add a table (currently in columns O:Q) that calls in itemised log records based on the category selected (O2) and the month and the year. On the reference sheet these are cells (B3) and (C3) respectively and in the log, these are columns (F) and (G).
I've gotten as far as using an INDEX / SMALL array formula combination to pull in all spending as per the category selected in (O2), but what I cannot seem to figure out is how to then restrict results to only those that also match the month and year. I've tried using a MATCH formula but am unsure how to append this within the current formula string, if it is even possible?
Once working, this would (for example) mean that only rows 4 and 5 in columns O, P, and Q would be populated as these are the records for the selected month, June 2016.
Is what I want to do possible through a more complex formula? Can anybody help?
Thank you in advance.
Link to my Google Sheet: https://docs.google.com/spreadsheets/d/1_GGgFCfMtB5ROkTmpx4Fn4nZZbBIvBa4vpOwqswH5E0/edit?usp=sharing
The following should do the trick.
Delete everything in O4:Q14
In cell O4, write: =FILTER(Log!H2:H, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
In cell P4, write: =FILTER(Log!E2:E, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
In cell Q4, write: =FILTER(Log!D2:D, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
(By the way, you can generate columns F, G and maybe E from column A in the Logs sheet. For example, just remove the data that is already in column G and in G2 write: =ARRAYFORMULA(YEAR(A2:A))
Link to spreadsheet with fixes:
https://docs.google.com/spreadsheets/d/1iIplXRa28L7FdmqI91RbjApO3g-GU5uk6rTQLqi7vFw/edit#gid=0

How to retrieve a cell value and write it in another sheet checking two different columns

I have two sheets, Progress and App1stSession, in the same spreadsheet.
Progress sheet has these columns
Date Campaign Sessions 1stSessions
App1stSession sheet these columns
Date Campaign 1stSessions
I need to retrieve 1stSessions values from App1stSession. The match can be done on Date and Campaign values.
I've written this formula
INDEX(App1stSession!$A$1:C,
AND(MATCH($B1,App1stSession!$B$1:B,0),MATCH($A1,App1stSession!$A$1:A,0))),3)
Of course it doesn't work because AND retrieves 0 or 1.
So I've tried this solution
INDEX(App1stSession!$A$1:C,IF(AND(MATCH($B1,App1stSession!$B$1:C,0),MATCH($A1
,App1stSession!$A$1:A,0)),MATCH($C1,App1stSession!$C$1:C,0)),3)
I suppose that the second MATCH could retrieve the right row: neither this solution works.
Finally I've tried
=QUERY(App1stSession!$A$1:A,"SELECT """&App1stSession!$C1:C&""" WHERE
("""&App1stSession!$A$1:A&"""="""&$A1&""")AND("""&App1stSession!$B$1:B&"""="""&$C1&""")")
Again it doesn't work but I suppose because of a matter of syntax.
Any suggestion ?
Thanks
The way I would do it, is insert one unique id column/search key in column A, before the rest of your data, that is dynamically created by the date & campaign values in your App1stSession sheet:
=B1&C1
then use this type of formula to smush the same two values together dynamically on your search sheet in a vlookup fashion on your progress sheet:
=VLOOKUP(A1&B1,App1stSession!A:D,4,false)

Resources