I am doing a test to calculate user retention for a bank. While doing so, I can certainly calculate the number of churn users and number of loyal users for a certain date period (for example, from 1 jan to 1 feb). However, the timeframe has every transactions/activities of every unique user from 1 jan 2016 to 1 jun 2018. I know we could do a loop in sql to automatically loop through every month but it is hard to do so with the calculation (with new users joining every month and the new users of month 1 would either be loyal user or churn in month 2).
Could anybody shed a light for me?
that's my first time here, I'm a begginer at Data Science.
I would like to ask for suggestions for the best way or algorithm to complete this task:
Predict the total month sale based in day of the week and the day of the month, so I think it could be simple as a weighted average, after measuring the impact of like Wednesday in the 5th day of month.
Total Sales = (1º Impact: of Day of Month, 2º Impact: Day of Month )
It would have to answer the following questions:
How is the month/week sale in relation to the average of expected for this day of week / month.
Create a profitable ranking for the combination of day of week / month.
I am trying to calculate a factor for each employee and month. The factor depends on the actual working days.
For example to calculate it for April (4/1/2019 to 4/30/2019) one employee is on vacation from 4/8/2019 to 4/12/2019 and he will leave the company on the 4/26/2019.
April has 30 days and the employee has 5 days off and 4 days without contract (so hasn't the possibility to work for 9 days). In this case the factor would be 0.7 = (1/30)*(30-9).
How is it possible to count the clashing days for each month? It is also possible that an employee is on vacation from 3/25/2019 to 4/5/2019 etc.
I am hoping to use openweathermap for forecast but on a daily basis (one forecast per day), instead of ever 3-hour per day forecast.
I don't thikn OWM have such an end point but is there away it can be calculated once data is retrieved?
I am trying to produce a query in SQLite where I can determine the average sales made each weekday in the year.
As an example, I'd say like to say
"The average sales for Monday are $400.50 in 2017"
I have a sales table - each row represents a sale you made. You can have multiple sales for the same day. Columns that would be of interest here:
Id, SalesTotal, DayCreated, MonthCreated, YearCreated, CreationDate, PeriodOfTheDay
Day/Month/Year are integers that represent the day/month/year of the week. DateCreated is a unix timestamp that represents the date/time it was created too (and is obviously equal to day/month/year).
PeriodOfTheDay is 0, or 1 (day, or night). You can have multiple records for a given day (typically you can have at most 2 but some people like to add all of their sales in individually, so you could have 5 or more for a day).
Where I am stuck
Because you can have two records on the same day (i.e. a day sales, and a night sales, or multiple of each) I can't just group by day of the week (i.e. group all records by Saturday).
This is because the number of sales you made does not equal the number of days you worked (i.e. I could have worked 10 saturdays, but had 30 sales, so grouping by 'saturday' would produce 30 sales since 30 records exist for saturday (some just happen to share the same day)
Furthermore, if I group by daycreated,monthcreated,yearcreated it works in the sense it produces x rows (where x is the number of days you worked) however that now means I need to return this resultset to the back end and do a row count. I'd rather do this in the query so I can take the sales and divide it by the number of days you worked.
Would anyone be able to assist?
Thanks!
UPDATE
I think I got it - I would love someone to tell me if I'm right:
SELECT COUNT(DISTINCT CAST(( julianday((datetime(CreationDate / 1000, 'unixepoch', 'localtime'))) ) / 7 AS INT))
FROM Sales
WHERE strftime('%w', datetime(CreationDate / 1000, 'unixepoch'), 'localtime') = '6'
AND YearCreated = 2017
This would produce the number for saturday, and then I'd just put this in as an inner query, dividing the sale total by this number of days.
Buddy,
You can group your query by getting the day of week and week number of day created or creation date.
In MSSQL
DATEPART(WEEK,'2017-08-14') // Will give you week 33
DATEPART(WEEKDAY,'2017-08-14') // Will give you day 2
In MYSQL
WEEK('2017-08-14') // Will give you week 33
DAYOFWEEK('2017-08-14') // Will give you day 2
See this figures..
Day of Week
1-Sunday, 2- Monday, 3-Tuesday, 4-Wednesday, 5-Thursday, 6-Saturday
Week Number
1 - 53 Weeks in a year
This will be the key so that you will have a separate Saturday's in every month.
Hope this can help in building your query.