1. This is a follow up post to Fiscal Calendar Calculations Cheatsheet for Tableau.

    Excel is a very important tool for data analysis and calculations. It's also an important data repository for Tableau. Some of the calculations can be made in Excel before the data is loaded into Tableau or other tools.

    So here we are going to show the conversion from a regular date to a week-based financial calendar date, via Excel formula. We still use Apple's 5-4-4 Fiscal Calendar as an example.

    The First Week of a Fiscal Year

    It is the week that includes October 1st which is an Anchor Date. From the first week, we can determine the Fiscal Year.

    Fiscal Year

    Here is the formula for calculating Fiscal Year.
    Note that B2-WEEKDAY(B2)+1 is the first day of the fiscal year. From this day on, the new fiscal year starts.

    The First Day of the Fiscal Year

    In the above Fiscal Year calculation, we used B2-WEEKDAY(B2)+1 to get the first day of the week that includes date B2. This is equivalent to DATETRUNC('week', B2) function in Tableau.

    Leap Fiscal Year

    A common fiscal year has 52 weeks and a leap fiscal year has 53 weeks. We will use this property to determine if a fiscal year is a leap year or not.
    This formula allows us to get the total number of weeks between the start dates of two consecutive fiscal years.

    The formula can be simplified a little: (E2-WEEKDAY(E2)-(D2-WEEKDAY(D2))/7

    The logic test can be written as E2-WEEKDAY(E2)-(D2-WEEKDAY(D2)=371. If true, then it is a leap fiscal year.

    Fiscal Week

    The fiscal week of a common date is its distance to the start week of the fiscal year.

    Fiscal Month/Period

    In a common fiscal year, we will have 5-4-4 weeks for each of the 4 fiscal quarters. In a leap fiscal year, we will have 5-4-5 weeks in the first fiscal quarter. That is, the 3rd fiscal month/period will have 5 weeks in a leap fiscal year instead of 4.

    Here is the formula for calculating fiscal month/period

    Fiscal Quarter

    It's easy to create the formula for getting fiscal quarters from fiscal months.

    Demo File for Download

    We have an Excel file for you to download (Click link and open it in Google spreadsheet. Go to File and click Download.) It has all the above formulas and all the fiscal years in the next 1000 years. Feel free to use it in your data analysis.

    Conclusion

    With the above formulas, we save the dependency on a database table for converting a common date to fiscal date. The above example is based on a 5-4-4 week-based fiscal calendar. It may not match exactly your fiscal calendar. Nonetheless it may give you some ideas for creating your conversion formulas.

    Feel free to leave comments or contact me at @aleksoft at twitter.
    0

    Add a comment

  2. Week-based calendars are used in many companies as their fiscal calendars. The total weeks in a fiscal year is 52 weeks, that is, 364 days. Each quarter has 13 weeks. There are 3 varieties of 13 weeks: 5-4-4, 4-5-4 and 4-4-5 weeks per quarter. In leap years, there are 53 weeks or 371 days. IRS has created special code for the 52-53-week fiscal years.

    Each company's week-based fiscal calendar will differ in 4 ways:

    - define the 13-week quarter as 5-4-4, 4-5-4 or 4-4-5
    - define its own start week 
    - define its own way of placing the leap week
    - define the first day of week as Sunday, Monday etc.

    Please refer to each company's official fiscal calendar for the exact design. This post is just a reference for the conversion of a common date to fiscal dates under given rules.

    Apple's Fiscal Calendar is widely disseminated on the web. Here we try to clarify some of the misunderstandings and provide calculation assistance in Tableau for analyzing time series based on the 5-4-4 format. We will use Apple's fiscal calendar as an example below.

    Common Fiscal Year

    In a common year, it's a 52-week year which has 52x7 = 364 days.

    A year has 4 quarters and each quarter has 3 fiscal periods/months. 

    Each quarter has 13 weeks.

    At Apple, the first period of a quarter has 5 weeks and the other two have 4 weeks each. It's thus called a 5-4-4 calendar.

    First Week of a Fiscal Year

    For a week-based calendar, it is very important to understand the definition of its first week. Each company may have a different definition of the first week.

    For Apple's fiscal calendar, its first week is the one that always includes October 1st. This week is the first one of the next fiscal year. For example, the week that includes 10/1/2022 is the first week of fiscal year 2023.

    First Day of a Week

    In Apple's fiscal calendar it's always a Sunday. There may be other conventions where we need to change the following calculations.

    Leap Rule

    Every 6 years or so, there will be a leap fiscal year. 

    A leap fiscal year will have 53 weeks, one more week than the common fiscal year. 

    The cause of the leap fiscal year is as follows:

    - A common fiscal year has 364 days while a common calendar year has 365 days. It is 1 day less than the calendar year. It seems that every 7 years, we need to add a week to the common fiscal year to realign the starting dates of fiscal years. But the 7-year frequency is broken by the leap calendar years because a calendar year doesn't always have 365 days. This makes it a lot less predictable when guessing which year is a leap year.

    - A calendar year has its own leap year which has 366 days. This happens on every 4 years on the years divisible by 4 and excluding the years that can be divided by 100 but can't be divided by 400.   

    The leap years in the next 100 years and the gaps in between.

    Leap Week

    In a leap fiscal year, there will be an extra week or a leap week. Where to place it depends on the company. In Apple's fiscal calendar, it's added in the third fiscal month which becomes a 5-week month during a leap fiscal year. That is, we insert the leap week after the 13th week of the fiscal year. Or the 14th week of a leap fiscal year is the leap week.

    Placement of the Leap Week

    We have an extra week in a leap fiscal year. It is appended to the end of the first fiscal quarter or the 3rd fiscal month/period. Thus, the first fiscal quarter, instead of 5-4-4 quarter and having 13 weeks, it becomes 5-4-5 quarter and having 14 weeks.

    How to Determine if a Fiscal Year is a Leap Year?

    This is easy. Just find out if October 1st in two consecutive years has a gap of 53 or 52 weeks. If 53 weeks, it is a leap year for sure.  So, use this logical formula:

    The First Day of a Fiscal Year

    The Sunday of the first week is the first day of the fiscal year.

    In Tableau formula, we can easily derive the first day of a fiscal year. For example for the fiscal year 2023, the first day is:

    DATETRUNC('week', MAKEDATE(FiscYear-1,10,1))

    Some says the first day is always the last Sunday of September. This is not exact. It's only about 6/7 correct. It's the Sunday within Sept 25th - Oct 1st. 

    The Last Day of a Fiscal Year

    It's actually the last Saturday in September. For any FiscYear, the last day is the first day of the next FiscYear minus one.

    DATETRUNC('week', MAKEDATE(FiscYear,10,1))-1

    Convert a Date to Fiscal Year/Quarter/Month/Week?

    Here are the Tableau formula we can use to convert a regular date to its corresponding fiscal date. Note that they are dependent on the ones above them.

    - What fiscal year is it in? We got FiscYear which is dependent on Order Date alone.

    - What fiscal week is it in? We got FiscWeek which is dependent on Order Date and FiscYear.

    - What fiscal month (period) is it in? We got FiscMonth which is dependent on FiscWeek and Leap Year T|F. (Credit Steve Fenn

    - What fiscal quarter is it in? We got FiscQuarter which is dependent on FiscMonth.

    Conclusion

    Note that each company may have its own way of defining its week-based fiscal calendar. Hope that this post can give you some ideas for deriving your own specific formula.

    Feel free to download this workbook and copy over the formula if you wish. Contact @aleksoft if questions. 

    0

    Add a comment

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.