Multiple IF statements using dates and blank cells - if-statement

I currently have a spreadsheet showing when work needs to be complete by (Finish No later than - N2) and the date it was completed by (Actual Finish Date - L2). In the formula I have written it will bring back the words Non Compliant or Compliant if the Actual Finish date was before or after the Finish No later than.
=IF(N2>$L$2,"Non Compliant - Complete","Compliant - Complete")
This works fine but I also need to add two further words based on whether there is any date in the Actual Finish Date column.
Can someone help me add an extra If function to the end of mine with following rules?
If the date is blank and the Finish No later than date is before today then it returns - Non Compliant - Open
or
If the date is blank and the Finish No later than date is grater than or equal to today then it returns - Compliant - Open
Thank you for looking

Related

Error in If-Else statement for Apple Script to resurface 1 year old notes

I'm trying to create an Apple Script that resurfaces a note from a year ago.
This is my code thus far:
set today to current date
set day of today to 1
set time of today to 0
set throwback to today - (365 * days)
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
if exists (note whose creation date is throwback) then
show (every note whose creation date is throwback)
else
display dialog "No notes from this day a year ago, check back in tomorrow!"
end if
end tell
end tell
end tell
I keep getting a script error that states "Can’t get note whose creation date = date "Monday, February 1, 2021 at 12:00:00 AM"."
But in the case that it cannot get a note, I'd like it to display the dialog written in the code above. When the if statement fails why does it not go through with the else statement?
Thanks!
You have to check for multiple notes (plural)
if exists (notes whose creation date is throwback) then

Searching within the result of a vlookup using a range of values and parsing text

MY GOAL:
parse a MM/DD date from the result of a vlookup so that it can be used in a project plan
BACKGROUND:
The vlookup result contains multiple values separated by a "•" (I don't need all of them)
The value I'm looking to parse is not always in the same location in the vlookup result (otherwise I could use the RIGHT formula)
There is a finite number of the values I'm looking to retrieve (and I know them already)
The value that I'm looking to retrieve contains some text with a date range; I only want the first four values in the date range (MM/DD)
I'd like to achieve all this with a single formula with the result in a single cell
CURRENT FORMULA
The formula that I've been working on that is not working is:
=ARRAYFORMULA(if(iserror(search(Iterations!D2:D7,(VLOOKUP(A2,'Results {2596503}'!$C$2:$L$183,3)))),,))
I've set up a sheet called "Erik Help" with the following formulas in B2 ad C2:
=ArrayFormula(IF(A2:A="","",MID(VLOOKUP(A2:A,data!A2:B,2,FALSE),FIND(REGEXEXTRACT(VLOOKUP(A2:A,data!A2:B,2,FALSE),"[0-9]-[0-9]"),VLOOKUP(A2:A,data!A2:B,2,FALSE))-4,5)))
and
=ArrayFormula(IF(A2:A="","",MID(VLOOKUP(A2:A,data!A2:B,2,FALSE),FIND(REGEXEXTRACT(VLOOKUP(A2:A,data!A2:B,2,FALSE),"[0-9]-[0-9]"),VLOOKUP(A2:A,data!A2:B,2,FALSE))+2,5)))
respectively.
They may be longer than actually needed, but you did not share realistic results in Column B or list which symbols may appear in Column B other than in the date; so I tried to account for either a hyphen or a forward slash possibly appearing in Column B in places other than within the date span.
Your analytics sheet also shows a formula that is sorting the results from data!A:A. So even though in your example the original data order happens to be the same as in analytics!A:A, that is not a given (again, based on your formula). Therefore, the VLOOKUP is also necessary.
You did not indicate whether you need to further use these returned date-snippets in calculations, or whether you just need to view them. So the results generated in "Erik Help" are text.
If you want usable numbers/dates, you add further issues that would need to be controlled for in the formula, because you'll only be extracting month and day, not year. That's fine right now. But what about when the date range to be extracted is "12/28-01/13"? If you simply make these values/dates, they will both be assigned to the current year. So the end date here will wind up being earlier than the start date.
Because of this, I've added a second sheet, "Erik Help 2," which contains extended formulas to account for these cases while still returning the date format you want as actual dates which can be used in calculations.
EDIT
(following your note on the sheet: "I would like to remove col b altogether and nest in the formulas in col c and d")
You can adjust the range B2:B by replacing it with your already existing formula in B2.
The new adjusted formula will become
=ArrayFormula(IFNA(SPLIT(REGEXEXTRACT(VLOOKUP(ARRAYFORMULA(sort(unique(data!A2:A))),data!$A$1:$C,2),"\d+\/\d+-\d+\/\d+"),"-")))
Original answer
You can use the following formula:
=ArrayFormula(IFNA(SPLIT(REGEXEXTRACT(B2:B,"\d{2}\/\d{2}-\d{2}\/\d{2}"),"-")))
Make sure you format the results as Date.
(Please adjust ranges to your needs)
Functions used:
ArrayFormula
IFNA
SPLIT
REGEXEXTRACT
try:
=ARRAYFORMULA(IF(A2:A="",,IFNA(TEXT(SPLIT(REGEXEXTRACT(
VLOOKUP(data!A2:A, data!A:C, 2), "\d+/\d+-\d+/\d+"), "-"), "mm/dd"))))

AWS IoT Analytics Delta Window

I am having real problems getting the AWS IoT Analytics Delta Window (docs) to work.
I am trying to set it up so that every day a query is run to get the last 1 hour of data only. According to the docs the schedule feature can be used to run the query using a cron expression (in my case every hour) and the delta window should restrict my query to only include records that are in the specified time window (in my case the last hour).
The SQL query I am running is simply SELECT * FROM dev_iot_analytics_datastore and if I don't include any delta window I get the records as expected. Unfortunately when I include a delta expression I get nothing (ever). I left the data accumulating for about 10 days now so there are a couple of million records in the database. Given that I was unsure what the optimal format would be I have included the following temporal fields in the entries:
datetime : 2019-05-15T01:29:26.509
(A string formatted using ISO Local Date Time)
timestamp_sec : 1557883766
(A unix epoch expressed in seconds)
timestamp_milli : 1557883766509
(A unix epoch expressed in milliseconds)
There is also a value automatically added by AWS called __dt which is a uses the same format as my datetime except it seems to be accurate to within 1 day. i.e. All values entered within a given day have the same value (e.g. 2019-05-15 00:00:00.00)
I have tried a range of expressions (including the suggested AWS expression) from both standard SQL and Presto as I'm not sure which one is being used for this query. I know they use a subset of Presto for the analytics so it makes sense that they would use it for the delta but the docs simply say '... any valid SQL expression'.
Expressions I have tried so far with no luck:
from_unixtime(timestamp_sec)
from_unixtime(timestamp_milli)
cast(from_unixtime(unixtime_sec) as date)
cast(from_unixtime(unixtime_milli) as date)
date_format(from_unixtime(timestamp_sec), '%Y-%m-%dT%h:%i:%s')
date_format(from_unixtime(timestamp_milli), '%Y-%m-%dT%h:%i:%s')
from_iso8601_timestamp(datetime)
What are the offset and time expression parameters that you are using?
Since delta windows are effectively filters inserted into your SQL, you can troubleshoot them by manually inserting the filter expression into your data set's query.
Namely, applying a delta window filter with -3 minute (negative) offset and 'from_unixtime(my_timestamp)' time expression to a 'SELECT my_field FROM my_datastore' query translates to an equivalent query:
SELECT my_field FROM
(SELECT * FROM "my_datastore" WHERE
(__dt between date_trunc('day', iota_latest_succeeded_schedule_time() - interval '1' day)
and date_trunc('day', iota_current_schedule_time() + interval '1' day)) AND
iota_latest_succeeded_schedule_time() - interval '3' minute < from_unixtime(my_timestamp) AND
from_unixtime(my_timestamp) <= iota_current_schedule_time() - interval '3' minute)
Try using a similar query (with no delta time filter) with correct values for offset and time expression and see what you get, The (_dt between ...) is just an optimization for limiting the scanned partitions. You can remove it for the purposes of troubleshooting.
Please try the following:
Set query to SELECT * FROM dev_iot_analytics_datastore
Data selection filter:
Data selection window: Delta time
Offset: -1 Hours
Timestamp expression: from_unixtime(timestamp_sec)
Wait for dataset content to run for a bit, say 15 minutes or more.
Check contents
After several weeks of testing and trying all the suggestions in this post along with many more it appears that the extremely technical answer was to 'switch off and back on'. I deleted the whole analytics stack and rebuild everything with different names and it now seems to now be working!
Its important that even though I have flagged this as the correct answer due to the actual resolution. Both the answers provided by #Populus and #Roger are correct had my deployment being functioning as expected.
I found by chance that changing SELECT * FROM datastore to SELECT id1, id2, ... FROM datastore solved the problem.

Writing a for loop in python that has the <= (smaller or equal) condition in it?

I want to iterate through different dates, for instance from 20/08/2015 to 21/09/2016, but I want to be able to run through all the days even if the year is the same. For instance 20/08/2015 to 25/09/2015.
Now if I write this in C, I could just use a for loop and make it so it runs if value of startYear <= value of endYear, but from all the examples I see online the for loop runs with the range function, which means if I give it the same start and end values it will simply not run.
For example:
startYear=int(raw_input("Starting year (yyyy):"));
endYear=int(raw_input("Ending year (yyyy):"));
for year in range(startYear,endYear,1):
As the input comes from the user I have no control over it. So if startYear and endYear are both 2015 I can't make it iterate even once. Note that I can't "cheat" by changing the values of startYear and endYear as I am using the variable year for calculations later.
I would love to know:
Is there a way to run a for loop in Python that checks for lower or equal?
What is the best way to go about writing this simple iteration?
Thanks
You can use endYear + 1 when calling range. Also note that passing 1 to the step argument is redundant.
for year in range(startYear, endYear + 1):
You can use dates object instead in order to create a dates range, like in this SO answer.

Unable to see whole output list on screen in C++ (Not even using scroll)

Ok, I just added a new feature to my student manager program (a console program written in c++) , it is a console application and my program print dates on which particular student is absent in a list format
by saying list format i mean 1 date on 1 line
this is how output looks like for student who is absent 5 times
1. 04/05/2016,Monday
2. 05/05/2016/Tuesday
3. 06/05/2016/Wednesday
(Assume dates are correct)
now since these are only 3 records that are printed on the screen, a user would not require scrolling down,
but in a case of 300 dates , it prints all dates but when i scroll up I'm not able to reach back to 1st date, for example, I'm only able to see last 147 Records only
and I'm not able to scroll my console window to 1st record.
I know many other ways to solve this problem (like displaying 10 records or 100 records at a time) but I want to know how can i solve this particular problem
please give answer considering me as a beginner. :)
Thank You.
(as far as code is concerned, i can assure you its nothing special, just a while loop that keeps on printing dates until certain terminating condition is met )