sameperiodlastyear when fiscal calendar is not month to month - powerbi-desktop

Is there a way to use the SAMEPERIODLASTYEAR function in Power BI when your fiscal calendar does not go month to month? Our monthly calendar ends on the last Saturday of the month. This is what I have
Current = CALCULATE(COUNTROWS('FactWholesale'))
Last = CALCULATE([Current],SAMEPERIODLASTYEAR(DimDate[Date]))
the Current months are always correct. an example
the current September 2017 is 594 and current month September 2018 is 578
the problem is sameperiodlastyear for September 2018 is 579 and it should be 594.
I believe what is happening is to figure sameperiodlastyear it is using 8/27/2017 - 9/30/2017 to figure. is there a way to make this work?
FiscalMonthStartDate FiscalMonthEndDate FiscalMonth
8/28/2016 10/1/2016 Sep-17
8/27/2017 9/30/2017 Sep-18

Related

WEEKNUM across multiple years

I am doing a cohort analysis for a subscription service from September 2021 - January 2023 and using the WEEKNUM formula, but of course each year starts on a different day and I am struggling to figure out how to mitigate this for all dates on the worksheet. Additionally, I just want there to be 52 weeks each year (not 53, week 52/1 can overlap years).
Presumably it will need to be some sort of IF statement but I just can't seem to visualise it!
I have tried =WEEKNUM(D2,15), which is fine for days in 2021 as it starting on a Friday, but not for days in 2022 and 2023 when I drag the formula down all of the dates
I think I've figured out the answer!
=IFS(D2<>"2023",(WEEKNUM(D2,1)),D2<>"2022",WEEKNUM(D2,16),D2<>"2021",WEEKNUM(D2,15))
I have tested it against some of the dates manually and it seems to hold true

Filter dates by month in pivot table that doesn't start with the 1st of every month

Does anyone know how to filter dates by specific dates by month such as Jan 15 to February 15, Feb 15-March 15....etc on pivot table in excel?
My data is January 15 2017 to January 15 2018, so I like to filter it by specific dates but so far it's only letting me do the number of days which is not accurate since feb has only 28 days. thank you!

YEAR() fitting to WEEKNUM(...,21) in Excel

I'm looking for a way to specify return 2015 for a date within this week, but in Calendar Year 2014.
This current week according to the Thursday system is Week 01/2015. But the Year function will still return 2014.
Something like:
IF(AND(WEEKNUM(TODAY(),21)=52,WEEKNUM(TODAY()+7,21)<>53),YEAR(TODAY())+1,YEAR(TODAY())
but a little bit more reliable and elegant.
Anybody got something?
Happy Happy
Ben-san
The "Year" of the week is determined by the year of the Thursday of that week (assuming ISO week numbers) so you can just find the Thursday and then get the year of that date, i.e. for any date in A1
=YEAR(A1-WEEKDAY(A1,3)+3)
or, similarly, for today's date
=YEAR(TODAY()-WEEKDAY(TODAY(),3)+3)
This works for any date in any year.......and might put days in Jan in the previous year also, e.g. 3rd Jan 2016 is in the last week of 2015

Microsoft Excel - Date Sequence

I had a look for this question before I asked, but sorry if it's a repeat.
In a spreadsheet, I want to employ a date sequence.
eg. Stock Arrives - Friday 22nd February 2013
then, on the 22nd of Feb, that date CHANGES to the next 7 days.
eg. Stock Arrives - 1st March 2013
and then repeats this indefinitely.
Is there any way to do this?
If you want to always show the next Friday you can use this formula
=TODAY()+8-WEEKDAY(TODAY()+2)
That will show Friday 15th Feb 2013 right now.....but on 15th feb it will change to showing 22nd Feb
For other days just change the +2 at the end, e.g. +3 will give you next Thursday, +4 will give you next Wednesday, +5 will give you next Tuesday etc.
This is some way you could do this though I am not sure if this is what you want.
=B1+FLOOR((TODAY()-B1)/7,1)*7
Basically, have a cell hold the start date of the stock inventory (first date in the past where you received this stock). You need to have also the number of days between restocking (here I hardcoded 7). Then you can just use the floor of the difference between today and that date divised by the restocking time. This will give you a step-function-style behaviour.

Does Excel have a function to calculate Canadian federal holidays?

I'm trying to figure out how to calculate the past/future Canadian federal holiday dates to use the NETWORKDAYS function in the cell. Because the dates of the holidays change every year, is there a function or VBA code that I can use to calculate this?
For example, I have a 10 year project and I want to calculate the variance between the beginning date and the end date, excluding the weekends and holidays.
Like, Civic holiday is on the 1st Monday of August. It was on the 1st in 2011, but in 2012 it was on the 6th.
Easter Monday was on the 25th in 2011, but on the 9th in 2012.
Becuase NETWORKDAYS need exact date of the holidays in order to work, I need to calculate the future holiday dates (10-15years into the future)
I hope this makes sense...
You can make a list quite easily with a formula approach e.g.for Labour Day list years only in A2 down and in another column in row 2 use this formula
=DATE(A2,9,8)-WEEKDAY(DATE(A2,9,6))
that will give the date of First Monday in September for the relevant year - copy formula down column
Edit: Here's a workbook with all holidays calculated from 2000 to 2099 as per your rules, I think. If you want dates before 2000 then just change the years in column A and the dates will change automatically
I would add a couple of blank columns to the range, e.g. make C2:M101 = holidays, then you can use that named range in any NETWORKDAYS/WORKDAY function - the extra columns would allow you to enter any "ad hoc" holidays
I know I'm a little late to the thread but for some reason the link to your file doesn't open. I would love to see how you calculate the Canadian holidays. I have found solutions for: Labour Day, Easter, Good Friday and Victoria Day but still looking for the rest.
Labour Day
=DATE(A2,9,8)-WEEKDAY(DATE(A2,9,6))
Easter
=FLOOR("5/"&DAY(MINUTE(A2/38)/2+56)&"/"&A2,7)-34
Good Friday
=FLOOR(DATE(A2,5,DAY(MINUTE(A2/38)/2+56)),7)-36
Victoria Day
=DATE(A2,5,25)-WEEKDAY(DATE(A2,5,25),3)-(7*(WEEKDAY(DATE(A2,5,25),3)=0))
* 4 digit year must be in A2 *
The working days are from Monday to Friday, excluding the holidays.
Some holidays taking place during weekend should be moved to next Monday (e.g. Canada Day, Boxing Day, New Year), or previous Friday (e.g. Christmas)
The following are the formulas for the holidays in the province of Ontario, Canada, if the fiscal year is in FYear
Holyday Formula
New Year =WORKDAY(DATE(FYear,1,0),1)
Family Day =DATE(FYear,2,22)-WEEKDAY(DATE(FYear,2,6))
Good Friday =FLOOR(DATE(FYear,5,DAY(MINUTE(FYear/38)/2+56)),7)-36
Victoria Day =DATE(FYear,5,25)-WEEKDAY(DATE(FYear,5,23))
Canada Day =DATE(FYear,7,1)+(WEEKDAY(DATE(FYear,7,2))<3)*(3-WEEKDAY(DATE(FYear,7,2)))
CivicDay =DATE(FYear,8,8)-WEEKDAY(DATE(FYear,8,6))
LaborDay =DATE(FYear,9,8)-WEEKDAY(DATE(FYear,9,6))
Thanksgiving =DATE(FYear,10,15)-WEEKDAY(DATE(FYear,10,6))
Christmas =DATE(FYear,12,25)-(WEEKDAY(DATE(FYear,12,26))<3)*WEEKDAY(DATE(FYear,12,26))
Boxing Day =DATE(FYear,12,26)+(WEEKDAY(DATE(FYear,12,27))<3)*(3-WEEKDAY(DATE(FYear,12,27)))
Next New Year =WORKDAY(DATE(FYear+1,1,0),1)
I found this page very useful, but I have a couple of additions. My use case is that I want to know when a stat holiday occurs even when it moves to a different day like Friday or Monday. These formulas apply to a table where #Year contains the year as a simple number.
U.S. Independence day behaves differently. If July 4 is a Saturday then the holiday is on 3 July. If July 4 is a Sunday then the holiday is 5 July. I found writing these as nested IF statements more straightforward:
=IF(WEEKDAY(DATE([#Year],7,4))=7, DATE([#Year],7,3), IF(WEEKDAY(DATE([#Year],7,4))=1,DATE([#Year],7,5),DATE([#Year],7,4)))
Next, the formulas above don't work for years like 2021 where Christmas and Boxing Day were a Saturday and Sunday. Again I think nested IFs work better.
We know that if Christmas Day (Dec 25) is on a Saturday, then the stat holiday is on Dec 27, and if it is on a Sunday then the stat holiday is Dec 26. =IF(WEEKDAY(DATE([#Year],12,25))=7,DATE([#Year],12,27),IF(WEEKDAY(DATE([#Year],12,25))=1,DATE([#Year],12,26),DATE([#Year],12,25)))
Similarly, we know that if Boxing Day is on either a Saturday or a Sunday (meaning Christmas was Saturday), then the stat is on Dec 28. And if it falls on a Monday (meaning Christmas was Sunday), then it moves to Dec 27.
=IF(OR(WEEKDAY(DATE([#Year],12,26))=7,WEEKDAY(DATE([#Year],12,26))=1),DATE([#Year],12,28), IF(WEEKDAY(DATE([#Year],12,26))=2, DATE([#Year],12,27), DATE([#Year],12,26)))

Resources