ArrayFormula for if Date is greater than Value - google-sheets

I'm trying to create a formula which pulls data from a separate sheet and selects only rows which fulfill a date comparison.
This is what I have at the moment:
=ArrayFormula(if('Complete Staff List'!E2:E < Date(2017;1;1), 'Complete Staff list'!B:C))
So in theory, it should pull all employees who started before 2017.
I understand how ArrayFormula works, but I can't manage to get the 'if' operation to work with it.

If I am interpreting your question correctly, you want to use query, not arrayformula.
In an unused cell with room for results,
=query(B2:E,"select B,C,E where E < date'2017-01-01'")
Dates as criteria in query are particular. See the section on dates in Google sheets query functuion and examples at More query function examples. From a separate sheet, use a named range to make life easy.

It should be like this:
=ArrayFormula(if('Complete Staff List'!E:E < Date(2017;1;1), 'Complete Staff list'!B:B))

Related

GoogleSheet Formula to Bring Back GoogleNews

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.

How do I get the range of holidays for NETWORKDAYS from a LOOKUP?

I am trying to grab a list of holidays from another sheet using an HLOOKUP to find the appropriate row based on country to get a list of holidays for the NETWORKDAYS function. However, when I try to do this I simply get a #REF error that says HLOOKUP evaluates to an out of bounds range.
I have a sheet called Billable Days that has a list of holidays based on country. Cells J14:N14 contains the country, and in a list below that is a bunch of holiday dates. They are varying ranges. For example, the US holidays range from J15:J32.
In a different sheet, I need to pull the correct holidays based on the country in column R into a NETWORKDAYS function.
First I tried:
=NETWORKDAYS(B2,S1,HLOOKUP($R2,'Billable Days'!$J$14:$N$14,15:50,FALSE))
This gives me an #VALUE error saying: "An array value could not be found"
Then I tried:
=NETWORKDAYS(B2,S1,ArrayFormula(HLOOKUP($R2,'Billable Days'!$J$14:$N$14,15:50,FALSE)))
Which gives another value error.
Finally, I tried
=NETWORKDAYS(B2,S1,ArrayFormula(HLOOKUP($R2,'Billable Days'!$J$14:$N$14,{15,16,17},FALSE)))
Just to test it out to see if I could get any values, and got a #REF error that said "HLOOKUP evaluates to an out of bounds range"
Can anyone help me craft this function? I'm not even sure if HLOOKUP is the way to go here, but it was the only way that came to mind.
EDIT
For clarity and as requested, I created a sheet to demonstrate what I mean. Find it here.
You will see the Consultants and Billable Days sheets. You can see the function I wrote to calculate the NETWORKDAYS based on the start and end date. However, in that function I want to add the appropriate list of holidays from the Billable Days sheet to the NETWORKDAYS function as the third parameter. I need something that looks at the country column and finds the appropriate holiday dates from the Billable Days spreadsheet, then inserts it into the NETWORKDAYS calls. I cannot figure out how to accomplish this.
Here is how to construct what you wish.
On the consultants sheet in L2 I placed =address(2,match(E2, 'Billable Days'!$A$1:$F$1,0)), which finds the column index of the desired country and construct a proper cell name for it with row B. Then in M2 I say ="'Billable Days'!"&L2&":"&mid(L2,2,1) to construct a string referring to the desired holiday range, like 'Billable Days'!$B$2:B. Columns L and M can be dragged down for all the people. Then when you want the holiday list for the consultant in the second row say =INDIRECT(M2) or in the 5th row =INDIRECT(M5), or if you are building it into another formula, drop the = sign. You could clean it up a little to be graceful when the country is not found, or possibly to make an ArrayFormula and avoid the dragging.

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

QUERY, FILTER or lookup for two conditions in Google Sheets

I'd like to create a column of simple formulae in the Holdings! tab of this Google sheet to do the following:
Look in Holdings!A for a company name
Look in Holdings!D for the date of the company's most recent round (ie the highest date)
Return the holding value in Rounds!C that matches both the company name from Rounds!A and the highest date in Rounds!B
I've tried to do it with QUERY, FILTER, INDEX and MATCH and looked at quite a lot of stuff on SO and Google product forums.
The general problem is to do a lookup-type function based on matching both of two conditions where I want an exact match with the first text condition and the maximum number (ie date) on the second condition,
Try any of the following formula in cell F2:
=filter(Rounds!C:C,Rounds!A:A=A2,Rounds!B:B=max(filter(Rounds!B:B,Rounds!A:A=A2)))
=+query(Rounds!A:C,"select C where A='"&A2&"' order by B desc",0)
and then drag it to the cells below it.

Sum / Counting items in a column that match 3 criteria

Thank you ahead of time for anyone who can help me with this, I think I am close, but it still isn't working.
I have a simple sheet activity reporting sheet that I am asking staff to complete over the upcoming year - It has 5 columns:
Column A: Date -In format (4/4/2013 13:30:00)
Column B: Title -In format (text string)
Column C: Attendance -In format (Numbers)V
Column D: Vol led - In format (text string)
Column E: Staff Led - In format (text string)
Using this data I am 90 % positive that I can aggregate on a different summary sheet that contains some static data like months (in the B column) to aggregate on. I am having trouble configuring the criteria in the filters though to cause the correct output to either sum or count .
Quantity of events ed by either staff or vol, if neither box is checked the event should not be counted) Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
Total number of attendance in a month for activities led by staff or volunteers Right now I am trying this but it is not working
=SUM(FILTER('Hostel Activities'!A:A,MONTH('Hostel Activities'!A:A)=$B3, NOT(AND(ISBLANK('Hostel Activities'!D:D),ISBLANK('Hostel Activities'!E:E)))
THIE WORKS! ## Heading ##Total number of volunteer led activities in a month for activities Right now I am using this and it IS working
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!E:E))))
Thank you for any assistance and/or guidance
Danny
The first problem I see with your first two formulas is that you're calling SUM on your FILTER result. But the FILTER is returning the column A, which are dates. So, your basically summing dates, which will surely not yield the result you're looking for. Why are you not using COUNT, as you did on your last formula?
Second, the first two formulas you pasted are identical, how do you expect them to return different results?
It seems that for the first two want to sum an OR condition. You can do this two ways (that I can think of now). The simpler to understand is just to sum two COUNT(FILTER(... formulas, one for each criteria, e.g.
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,not(isblank('Hostel Activities'!D:D)))) + B6
Assuming that on B6 is the other COUNT formula (the 3rd one, that already works).
Another option would be to use an OR function as criteria for the FILTER. Like this:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3, OR(NOT(ISBLANK('Hostel Activities'!E:E)), NOT(ISBLANK('Hostel Activities1!D:D))) ))
I believe I have figured out a method that works by making some adjustments in the formulas and the source data.
Basically
IN THE SOURCE REPORTING DATA:
I combined columns D and E into the same column and added data validation so the coordinator has to enter if the activity is led by staff,volunteer, or neither.
IN THE MONTHLY AGGREGATION REPORT:
To count the number of activities led by either staff or volunteers I used this :
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff"))+E3
*E3 is the count of volunteer led activities which is found using this formula:
=COUNT(FILTER('Hostel Activities'!A:A,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Adding up the number of participants in activities run by either staff or volunteers was a little more difficult, but I was able to do it by adding up 2 unique equations. I would prefer using an OR statement in the filter criteria, but I just couldn't get that to work. This is how I was able to make it happen:
=SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Staff")) + SUM(FILTER('Hostel Activities'!C:C,month('Hostel Activities'!A:A)=B3,'Hostel Activities'!D:D="Volunteer"))
Thank you all for your assistance

Resources