I have constructed a demo on
there is problem of 3 month ratio I am looking for when it’s Jan it will show Jan amount, if Feb then sum(Jan and Feb), if March then (Jan and feb and mar), if apr then sum(feb,mar,apr).
for April (Feb , March and April ) is because if we check last months there is Jan , Feb , March and April
but here we need only 3 months so this should be start form Feb ..
To calculate 3 month rolling average in chart please use:
RangeAvg(Above(Sum(B_Amount),0,3))
Related
Does anyone know of a quick algorithm to convert year over year returns to single period returns? Python code would be appreciated!
For reference, year over year refers to returns being calculated on an annual basis, for statistics that are reported on a higher frequency (to remove seasonality). So e.g. if total gas consumption is reported every month, the year over year return would be the percent difference between Dec 2018 and Dec 2017 and the single period return would be the difference between Dec 2018 and Nov 2018
So assuming you only have a series of YOY changes, is there a way to return monthly changes (in the above example)
tldr: I have a data series of year over year returns
ret(Jan 2017 to Jan 2018) = 1%
ret(Feb 2017 to Feb 2018) = -1.5%
ret(Mar 2017 to Mar 2018) = .5%
how do I convert it to a series of monthly returns?
ret(Jan 2017 to Feb 2017) = ?
ret(Feb 2017 to Mar 2017) = ?
...
Question: "So assuming you only have a series of YOY changes, is there a way to return monthly changes?"
Answer: No.
This can be demonstrated with a simple example. Here are four sample points:
Jan 2017 100
Feb 2017 90
...
Jan 2018 200
Feb 2018 180
The single period returns are -10%, and the year over year returns are +100%.
And here's another set of samples with the same year over year returns:
Jan 2017 100
Feb 2017 150
...
Jan 2018 200
Feb 2018 300
The single period returns are +50%, and the year over year returns are +100%.
Bottom line: the year-over-year returns tell you nothing about the month-to-month returns. To compute the month-to-month returns, you would need the monthly figures for at least one of the two years, in addition to the year-over-year returns.
Why does the number of the week of the year start with 1 in 2017 and 0 in 2018?
Date.strptime('2017-01-01', '%Y-%m-%d').strftime('%Y-%m-%d %U') #2017-01-01 01
Date.strptime('2018-01-01', '%Y-%m-%d').strftime('%Y-%m-%d %U') #2018-01-01 00
From the Ruby docs
Week number:
The week 1 of YYYY starts with a Sunday or Monday (according to %U
or %W). The days in the year before the first week are in week 0.
%U - Week number of the year. The week starts with Sunday. (00..53)
So it seems that Ruby identifies the "first week" (week 1) as starting with the first Sunday of the year. Anything that happens to come before that exists in week 0. 2017 happened to start on a Sunday, so the first day started the first week. However, 2018 started on a Monday, so week 1 of 2018 will start on January 7th, the first Sunday of the year.
To show week numbers according to ISO-8601, use %V:
# %V - Week number of the week-based year (01..53)
Date.strptime('2017-01-01', '%Y-%m-%d').strftime('%Y-%m-%d %V') #2017-01-01 52
Date.strptime('2018-01-01', '%Y-%m-%d').strftime('%Y-%m-%d %V') #2018-01-01 01
In general:
Week number according to the ISO-8601 standard, weeks starting on Monday. The first week of the year is the week that contains that year's first Thursday (='First 4-day week').
https://www.epochconverter.com/weeknumbers
I need to get time difference in minutes for my analysis in Hive query.
I am using unix_timestamp() to convert dates to seconds and then subtracting to get the diff in seconds and the multiplied by 60 for minutes.
My issue is my recent date - older date difference is coming negative.
here is my query and results
Hive query and result screenshot
processed_ts create_ts processed_unix_timestamp create_unix_timestamp miniue Diff
2017-03-12 3:01:06 2017-03-12 2:58:36 1489312865 1489316315 -57.5
2017-03-12 3:01:36 2017-03-12 2:59:06 1489312895 1489316345 -57.5
2017-03-12 3:02:12 2017-03-12 2:59:42 1489312932 1489316382 -57.5
Any help is much appreciated.
USA & Canada Start DST on March 12
Published 17-Feb-2017
Most of the United States, Canada, and Mexico's northern border cities
will begin Daylight Saving Time (DST) on Sunday, March 12, 2017.
People in areas that observe DST will spring forward 1 hour from 02:00
(2 am) to 03:00 (3 am), local time.
Standard time will resume on
Sunday, November 5, 2017.
https://www.timeanddate.com/news/time/usa-canada-start-dst-2017.html
select timestamp '2017-03-12 02:58:36'
2017-03-12 03:58:36
Requirement:- We are displaying timezone of the current date. Not the date what we received. It will fail all test case once the tz changes to PST We need to display the corresponding time zone of the date not the current timezone of the system for all dates Eg,
Daylight Saving Time (United States) 2016 began at 2:00 AM on Sunday, March 13 and ends at 2:00 AM on Sunday, November 6 03/13/2016 01:59:59 - PST 03/13/2016 02:00:00 - PDT 04/21/2016 00:00:00 - PDT 11/06/2016 01:59:59 - PDT 11/06/2016 02:00:00 - PST
Current solution:
Currently we take Date/Time value from Database and add PDT offset to match the value in UI:
For example:
db_hash["STATUS_STATE_UPDATED_DATE"] = db_hash["STATUS_STATE_UPDATED_DATE"] + Time.zone_offset("PDT")
This is done in all step defs where we are verifying UI data with database.
Also we are appending string "PDT" to database value to match the date/time displayed in UI.
db_hash["STATUS_STATE_UPDATED_DATE"] = db_hash["STATUS_STATE_UPDATED_DATE"].gsub("-","/").gsub("+0000","PDT").strip
We will have to fix this in all the step defs as per the new requirement.
I am current writing an application and need to show the current days of the week.
So, for the coming week I need to generate the follow dates.
Monday, 5 January 2009
Tuesday, 6 January 2009
Wednesday, 7 January 2009
Thursday, 8 January 2009
Friday, 9 January 2009
I have already coded the application to generate five dates from the current date. The problem I have is finding a method to create Monday through to Friday on the current week.
I am running OS X 10.5 and am using the Cocoa environment.
Look at NSCalendar and NSDateComponents.
If you haven't, you should read Dates and Times Programming Topics for Cocoa for more info/help.