What is KSP date formatting? - data-mining

I am dealing with a dataset and I have to deal with the date formatting. I need to know different ways I can use this dates feature to predict the data.
Thanks

There are different ways to use this date data. For example, if your date is x implies it is the distance from the 1st of the month. Similarly, it is some distance y months from the first of the year (January).
The day also matters. If the day is Friday => it's 5 days from the week start. You can include this as a different feature.
KSP is another way of reducing the date into a useful feature. Year +(#ofdays from the start of the year -0.5) /#ofdays in the year(356 or 355) leap year or not a leap year.
Hope this is useful.

Related

How to graph by 7 day periods in Power BI

Power Bi gives you the option to look at data by Year, Quarter, Month, and Day. I want the ability to look at data by 7 day periods that start on a specific date (not necessarily Monday or Sunday). How is the best way to accomplish this? I am guessing it will be with a measure but I can't quite figure out what the measure should look like?
Here I know I can assign a day of the week to each row and then use Week Day on my date axis. My problem is I need to be able to put "Tuesday" in the second parameter instead of either 1. Sunday or 2. Monday.
Week Number = WEEKNUM(Sheet1[Date],2)
Thank you in advance!
IIUC, the following might work:
Week number = WEEKNUM(DATEADD([Date],1,DAY),2)

Cumulative/Rolling Sum Blank Dates

I'm currently working on inventory reconciliation, and I've struggling to fill all days of the calendar with the cumulative sum of product we're currently storing:
Inventory level ($). = CALCULATE(SUM(ledger[cost]),FILTER(ALL(DimDate[Date]),DimDate[Date]<=MAX(ledger[Document Date])))
As you guys might notice it has at least 90% of all dates filled, however if we look closely to the graph, we can appreaciate March 5th of 2016 is missing just due to the fact there was no transaction during that day resulting on a blank value. However I'm trying to accomplish retrieving the previous day balance for those days with no transactions. e.g: for March 5th should have $17,038,462.32 (balance for the previous day March 4th).
I'm trying to work on another clause into the measure with functions such as EARLIER or LASTDATE, however I haven't been succesful.
Any insight or solutions works well thank you. Have a nice day.
You are using a wrong date field in your measure. Change it to the field from the Date table:
Inventory level. =
CALCULATE(
SUM(ledger[cost]),
FILTER(ALL(DimDate[Date]),DimDate[Date]<=MAX(DimDate[Date])))

Calendar table with changing start date

I work in an educational department where the start date of our academic calendar changes every year. Some years it might be week 9 of the year, some years it might be week 10. There is no formula used to figure out this start date, it's based a combination of factors and is picked by humans.
I want to be able to compare calls received in week 1 of the academic calendar 2017 to calls received in week 1 of the academic calendar 2018 and 2019.
I am using PowerBI desktop and trying to create a calendar table that includes a column "academic calendar week" or similar.
Does anyone have any suggestions on how to offset start date of the calendar by a different number of weeks for each year?

How to Get the Monthly Sales Prediction for next year using the sales history records of past 5 years?

I need to develop a system where user can analyse the past sales records and can predict monthly sales for next year. There I am using simple linear regression and get the past monthly sales records of past 5 years and create a line chart.
X= month
y= sales
e.g. I get the sales of month January for 5 years and get the average and plot the graph for 12 months. So how could I give user to predict for monthly sales for next year based on the graph of linear regression equation?
Also I would like to know whether my approach is correct? or are there any efficient ways to do that?
thanks
Welcome to forecasting. Your question doesn't quite belong here (as MBaas points out, stackoverflow is about teh codez), but while you are here you might as well get started with an excellent book, free and online, Rob Hyndman's Forecasting: principles and practice.
https://www.otexts.org/fpp
Once you have a code-related forecasting question, stackoverflow is the place for it! Hyndman even answers an occasional question here.

Finding the day of the thirteenth of every month over a period of years

I am currently trying to solve some problems from the USACO training website in preparation for an unrelated C++ programming competition.
However, I am stuck on this problem:
Does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.
The number N is provided in an input file and the output is to be a file with seven numbers in it, each representing the number of 13th's falling on a particular day of the week.
I was wondering how you guys would approach this problem. I am not looking for code or anything since that would just defeat the purpose of me doing this, instead just a starting point or an algorithm would be helpful.
So far the only thing I could think of is using the Doomsday Algorithm, however I am unsure about how I would implement that in code.
Any help would be greatly appreciated.
As Denny says, N is so small that you can easily iterate through the months using a table of days-in-a-month and a simple is-a-leap-year predicate to handle February. Just find out what day the 13th of Jan was in 1900 and then add up the elapsed days until 13th Feb, then 13th March etc.. Use a % operator to wrap the # of elapsed days back into a day-of-week value.
N is less than 400? well you just need to go over 365.25*400=146100 days at max. sounds easy to enumerate all of them, convert dates into year/month/date (with your favorite date conversion routine), testing for day of week is trivial.
I would precalculate the table though.
Just use brute force. Like this pseudocode example:
from datetime import date
day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday', 'Sunday']
counts = [0] * 7
for year in range(1900, 2300):
for month in range(1, 13):
counts[date(year, month, 13).weekday()] += 1
for day, count in zip(day_names, counts):
print('%s: %d' % (day, count))
The "hard" part is calculating the day of the week a date falls on. In C(++), you can use the mktime and localtime library functions if you know that your platform handles a large enough date range.