Business Intelligence: how to measure the impact of the day of week/month to the month sales - data-science

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.

Related

Power BI - Difference between amount per day and total in a table

I have a table with the sales from last 2 years, and I want to compare the sales from this year with the same natural day last year. For example, Sunday 1st of April 2018 will be compared with Sunday 2nd April 2017.
In order to do that I have created the measure
sales_last_year = CALCULATE(Sales[Revenue]); SAMEPERIODLASTYEAR(DATEADD('Calendar'[Date];+1;DAY)))
And I have created another measure where I have the value from the same day last year:
Prueba_sales_last_year = CALCULATE(Sales[Revenue]); SAMEPERIODLASTYEAR('Calendar'[Date]))
The result is the following:
Sales last year
As you can see the sales per day shows 5.316€ and 3.546€, which is correct, but the total is 111.796 €, which is not correct. However, the measure with the formula without the natural day the sum of the two rows is correct. How could I solve this?
Thank you very much in advance
I just changed the order to calculate the date and it was solved.
sales_last_year = CALCULATE(Sales[Revenue]);DATEADD( SAMEPERIODLASTYEAR('Calendar'[Date]);+1;DAY))

SQLite - Determine average sales made for each day of week

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.

How do I summarise month to date forecast for current month in Power Pivot?

I have a table in a data model that has forecast figures for the next 3 months. What I want to do is to show what the forecast number for the current month to date is.
When I use the DATESMTD function like this:
=CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]),DATESMTD(DateTime[DateKey]))
I get the last month of my data summarised as a total. I assume that is because the DATESMTD function takes the last date in the column and that is 3 months away.
How do I make sure I get this current month MTD total rather then the end of the calendar? The formula should be clever enough to realise I am in May and want the May MTD not the August MTD.
Any ideas?
The way to do this is to do this:
Forecast_Transaction_MTD:=CALCULATE(sum('ATO Online'[2017 Transaction Forecast]), DATESINPERIOD('ATO Online'[Current Year],TODAY(),-day(TODAY()),day))
the last -day(TODAY()) gets the day number for the current day and subtract it from today's date. So, today is the 25 May. the -day(TODAY())),day)) extracts the day (25) and subtracts it from the current date to get me to the 1 May.
The rest of the formula just adds the total for the dates.

SQL (Access), subquery: Find saleperson that exceeds $2000 in sales by month and what date in the month sales exceed $2000

I'm having trouble creating a subquery in Access to cough up what I need:
Input: SalespersonID, Amount, Date
I need to find what SalespersonID exceeds $2000 in a month (easy) AND what day in that month the running sum of Amount for that month exceeded $2000 (argh!).
I can groupby and get the first month any salesperson sum Amount > $2000 but I just can't figure out how to get the first date in that month when the month running sum of Amount>$22000
So you've got running-total in your tags - what did you try?
I would create a temporary table and generate the running total, and derive the month using the 'Month' function, and also derive the day of the month. If you sort by month and day each month's data will give you a running total that is what you want. This means you go month-by-month, and calculate the temp table for all salespersons.
It's not super elegant, but it'll give you what you want.

billing module

I'm launching a small service and plan to charge monthly (eg- will be advertised as $10 monthly). I'm working on the billing module right now but was wondering about a small bit:
I plan to bill customers when they first register and then at regular intervals thereafter. Getting to my question- Some months have less than 30 days. Does monthly billing imply exactly a 30 day interval or would anything between 28-30 days be considered a monthly interval?
I was planning on doing 30 because it seems that's what customers would expect, but I'm also curious if some companies charge at a fixed interval other than 30 days.
Billing monthly is assumed to be 12 times per year, not once every thirty days.
Preferably, billing should be on the anniversary of the original billing date of the month. If the current month has fewer days than the original billing DOM, bill on the last day of the current month, but on the next month, bill again on the anniversary day.