Accounting for leap year in comparing year to year sales - statistics

I am writing a program that shows the current years sales from the beginning of the fiscal year to the current date, compared to the same date range of the year before.
My question is, what efforts do I need to take for leap year?
UPDATE:
OK they want it like I said (compare last year up to same date) but if today is non leap year and last year is and today is feb 28th compare to last year up to 29th. Or if today is Feb 29th compare to last year up to 28th.

This strikes me as a business decision. Depending on the type of business, that extra day may not matter. Otherwise, I suppose you could treat is as "first n days of the year" rather than "Jan 1 through X".

Here's an idea, but like others have said it might be based on your specific domain.
Consider 1 "normalized" year = 365.242199 days counting all the leap stuff (says google)
Calculate the average sales per day in your year based on the real number of days in that year
Scale it up or down to sales per 365.242199 days
So for example
2007 = $4000 in sales.
There's 365 days in 2007, so avg sale per day = $10.96
Multpiplying times num days in a normalized year (365.242199)
gives you $4003.05 normalized sales
You can compare this directly to a similar calculation for 2008,
2008 = $5000 in sales.
There's 366 days in 2008, so avg sale per day = $13.66
Multpiplying times num days in a normalized year (365.242199)
gives you $4975.655 normalized sales for 2008!

You could scale down the leap year values to take the extra day into account.
So if you compare, say, the 1st of September of a regular year with the 1st of September of a leap year you would do:
if(year == leapyear && day > 28Feb)
Convert date to dayOfYear
leapYearValue *= dayOfYear / (dayOfYear + 1)
This should really be in the specification, though.

Related

Returning a Financial Year & Quarter date in Excel

I would like Excel to be able to return the related Financial Year and Financial Quarter of a particular date. i.e.
Date
1st April 2020
Financial Year
20/21
Quarter
Q1
Our financial year begins from 1st April (not 1st January) and the quarters fall from that date.
What equation can I use in Excel to make this work?
Please see below table denoting what a financial year looks like for us and the relative 4 quarters.
Thank you
David
Quick and dirty (can be simplified):
Financial Year:
=IF(MONTH(B1)>=4,RIGHT(YEAR(B1),2)&"/"&RIGHT(YEAR(B1),2)+1,RIGHT(YEAR(B1)-1,2)&"/"&RIGHT(YEAR(B1),2))
Quarter:
="Q"&IF(ROUNDUP(MONTH(B1)/3,0)-1=0,4,ROUNDUP(MONTH(B1)/3,0)-1)
You can try using for Financial Year:
=IF(MONTH(B1)>3,YEAR(B1)&"/"&YEAR(B1)+1,YEAR(B1)-1&"/"&YEAR(B1))
& for the quarter:
="Q"&CHOOSE(ROUNDUP(MONTH(B1)/3,0),4,1,2,3)

Is there a way to set monthly deductions on a value?

This is for personal budget and savings within an excel sheet.
Say I have a loan of £1000, I will be paying £10 per month as of 7th December 2019 until the amount is paid off.
I would like to have a summary page on my sheet displaying the current outstanding debt. Currently I can only seem to work out how to deduct the £10 if date greater than/ equal to 7th. Which is not useful as each month after the 7th it'll display £990.
What about DATEDIF:
=1000-((DATEDIF(43806,TODAY(),"M")+1)*10
Where:
1000 - Your starting loan
DATEFIF - Function to calculate difference between two dates in months
43806 - 1st Parameter: Starting date > 7th December 2019
TODAY - 2nd Paremter: Volatile function to feed the second parameter with current date
M - 3rd Parameter: Calculate difference in whole months
+1 - Amount of months + 1 to account for all payments
*10 - Difference in months times 10 to deduct from starting loan
This would be volatile though, so use sparsely.

Rolling 3 Current Year and Same Period Previous year total

Looking for a solution to sum a measure for the rolling 3 month period through the last date of data available (typically each end of month) for the current year and the same period in the prior year.
I've solved the current year total with this formula
SUMX(DATESINPERIOD(Ad_Data_for_Excel[AD START],
LASTDATE(Ad_Data_for_Excel[AD START]),-3,MONTH),
[Ad Count])
I have a data sheet with a dynamic ending date that is typically through the end of the prior month (e.g. September 30th data completed in October) and I'm trying to solve for a sum of the items for the latest Rolling 3 month period to be mirrored by the same Rolling 3 month period for the prior year (to make a comparison of the 3 month periods simple). It's just a simple sum and I have this year solved but haven't been able to find a solution for the same period prior year. Thanks for any help!

DAX year over year comparison

In a report that I am making in DAX I would like to have year over year comparison of a measure defined as:
Sales Count := CALCULATE(COUNT(fData[PN]);fData[Proc.Type]="CU")
This measure basically counts the amount of sales that were generated. I have a dataset that spans from the beginning of 2014 up to today (16/01/2018). My calendar table consists of a date column, a year column and a month column and is ranges from 01/01/2014 up to 31/12/2018 (to avoid contiguous date errors when using time intelligence functions).
I have defined a measure called PY Sales count as:
PY Sales Count := CALCULATE([Sales Count];SAMEPERIODLASTYEAR(dCalendar[Dates]))
This measure does the job I want it to do, aside from one issue. When comparing the month of january of this year to the month of January to last year, it appears that we are doing terrible. This is because the SAMEPERIODLASTYEAR function considers the FULL month of January for the year 2017 and compares it to the period from the first of January until the 16th of January (today).
I think I should thus try to build a custom measure to 'filter' the date table such that when the year over year measure considers the running month, it only takes the same period as the one on which sales were recorded to compare against, not the full period...
However, due to my sparse DAX experience, I cannot seem to get this right...
If anyone could help/assist me on this, that would be hugely appreciated!
Thanks in advance
I haven't had a chance to test this, but try something along these lines:
PY Sales Count := CALCULATE([Sales Count];
FILTER(dCalendar;
dCalendar[Dates] <= DATEADD(TODAY(), -1, year);
SAMEPERIODLASTYEAR(dCalendar[Dates])))

Excel - Times a month and day occur between 2 dates

I have an Excel sheet where someone types in the date for a yearly bill. I need to know how many times we need to pay that bill between 2 dates.
For example if a bill is due every year on May 31st, the user will type in 5/31/2014. I need to know how many time we will pay that bill between 5/15/2014 and 5/15/2018. (The between dates will change). I can't just take the number of years between the start and end dates because in the example above the start and end dates could be 6/1/2014 and 5/30/2018, in which case I only have to pay the bill in 2015, 2016, and 2017, which makes 3 times.
I have this formula which calculates the number of times a certain day occurs between 2 dates: SUMPRODUCT(--(DAY(ROW(INDIRECT($Q$2&":"&$R$2)))=F4))(Q2 is the begin date, R2 is the end date, and F4 has the day of the month) But I can't figure out how to get this to work for a month and day.
Assuming the specific date in G4 you can use this version
=SUMPRODUCT(--(TEXT(ROW(INDIRECT($Q$2&":"&$R$2)),"ddmmm")=TEXT(G4,"ddmmm")))

Resources