Calendar table with changing start date - powerbi

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?

Related

Create a date filter showing 12 rolling calendar months starting from EOM

I have a process where I have relationship between my sales table and my custom date table. My sales data gets its' filter from the custom date table. I have a process where I have 3 refreshes in 3 consecutive days starting from EOM of "previous month" and show last 12 calendar months.
I start this process end of every month i.e. For February data report I start on 02/28/2023 that will be my first refresh to filter sales data for last 12 calendar months (03/01/2022-02/28/2023). The next following day (03/01/2023) the second refresh need to filter (03/01/2022-02/28/2023).Then the final refresh is the next following day (03/02/2023) also need to filter (03/01/2022-02/28/2023). I couldn't use the standard filters in PBI since the eom is an exception. I have tried to create custom table using a formula where I add 7 days to today(02/28/2023) so I can go forward in time for my first day(02/28) and come back a month so I can get whole 12 calendar months. This wouldn't matter for the next month(03) since 7 days is not going to make any difference for month filter. I tried below custom table formula however it didn't work. Perhaps there is a better way to handle the exception indicated below
Table = CALENDAR(DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()+7)),TODAY())

Power Query - How to create a perpetual calendar with holidays

I would like to create a perpetual calendar in Power BI (Power Query) with the holidays. The thing is, I live in Canada and Easter and Victoria Day are quite complicated to integrate in this kind of calendar.
For the perpetual calendar, I used this technique (you can find the code on this website), which is very effective. It's "simply" a function to which you tell that you want a calendar from this date to this date and it generates everything you want and probably more. However, the calendar doesn't know which day is a holiday. So you need to have another request in Power BI with all the holidays for that period. Then you tell the calendar to use this holiday request as a reference point and then it will know which day is a holiday.
This is where it gets very complicated. Some holidays are based on a specific date, some are based on a specific day and others vary a lot.
Based on a specific date : New Year's Day, January 1st ; Saint-Jean-Baptiste Day, June 24 ; Canada Day, July 1st ; National Day for Thruth and Reconciliation, September 30 ; Remembrance Day, November 11 ; Christmas Day, December 25 ; Boxing Day, December 26.
Based on a specific day : Labour day, first Monday of September ; Thanksgiving, second Monday of October.
Those that vary a lot : Good Friday, Friday before Easter ; Easter, first Sunday after the Paschal full moon ; Easter Monday, Monday after Easter ; Victoria Day, last Monday preceding May 25.
Finally, some holidays happen only once to commemorate specific events like the death of the Queen on September 19, 2022.
I would like to create a function to which I indicate that I want all holiday for a specific period and it generates everything by itself. Then I could tell my calendar function to use it as a reference to know which day is a holiday. It would also be great if I could add some new holiday here and there for specific events like the death of the Queen.
For holidays like New Year's Day, Canada Day and Thanksgiving, I used this tutorial, but it's incomplete. Also, it doesn’t explain how to integrate holidays like Easter or Victoria Day. So this is where I'm stuck right now.
I know it's complicated but if someone can help me, it would be awesome.
As Jon suggest, I think it will be a lot easier to use the canada-holidays.ca/api.
I'm having issues with this API though. If I want multiple years in a single request, I need to create a request for each year and then append them. I'm trying to find a way to only have a single request but I'm struggling with this as well.
As soon as I find a solution, I'll update this post.
EDIT
Someone help me with that on another post. You can find the solution right here!

Power Bi DAX: Weekly Column for only working days

I need help working out the working days so i can calculate a weekly target by:
target / Working days in a Month (Total) = Daily Target
Daily Target * Working days in a week = Weekly Target
My target is set on the 1st of the month so that is why i need to spread it across weeks.
My columns:
Date
Month
Year
Week Number (1-52)
Week day (1-7)
Weekinmonth
Working day (1 & 0)
Day in Month (1-31)
What i need:
I need to list out the dates filtering out the working dates as another column (Does not show the dates that are on the weekend, these will be blank), need to return the working days as 1-31 as another column (same as the DAY function) so i can make a MAX formula to get the Working days in a month to by divided by the target to make the daily target. I am unsure how i will get the Working days in a week.
Can anyone help??

Power Bi DAX: Reset Value past a date

Run into a problem.
I need to have a yearly reset on an entitlement value but the reset point is a different date for each person. A person gets entitlement 6 months after their start date, so that +6months date is when they should have a reset. Here is the +6months column i made:
+6m = DATE(YEAR('Employee List'[Emp. Dates]),
MONTH('Employee List'[Emp. Dates])+6,
DAY('Employee List'[Emp. Dates]))
I ran into this problem when i saw that the excess was taking away a persons entitlement by the amount of days took throughout their entire time at the company. Here is the measure for Excess:
Excess Days = CALCULATE(SUM('Employee List'[Entitlement]) -
SUM('Leave combined'[Duration1]))
This is taking away all recorded days even from a few years ago.
Can i make a measure that pretty much says if we are past the +6months date (DD/MM(Year doesnt matter i just need the same time every year)), then it will take away their entitlement from that +6months date and will not pick up any days from before the +6months reset?
e.g. if the +6months is March 1 2015, currently it is taking all the days took from their start to today, i want it to reset at every year on March 1 so it would only take data from March 1 2019 - today and will reset once we past March 1 2020. If a person has took 25 days a year on average and they only have 20 days entitlement, it should show they 5 excess days but for me now it is taking the total days took away from their entitlement.
I understand this is hard to explain and you may not get it but i am happy enough to explain.
Dummy Sheet
It is easier to create a calculated column to do this. Perhaps something like:
Calc =
VAR Person = TableA[Person]
VAR Date1 = EDATE(Entitlement[Start Date],6)
RETURN IF(TableA[Start]<Date1,0,TableA[Duration])
This column will make the duration 0, wherever the start date is lesser than the +6m date from entitlement. Once this column is created you can simply sum up the field at whatever level required, to get the desired output. Hope this helps.

Calculating number of Months from one date to another in power bi

I was wondering if there is a way to calculate how many months it has been from one date to another in Power Bi.
For example the date would be October 1st 2014 and I would want to calculate how many months ago that was to the current date.