How to create fiscal calendar in Incorta?(Part 2)

This is the second part of the fiscal calendar MV, the Spark SQL part, through this part we can get day number, day name, fiscal week number, fiscal year start date, fiscal week end date, fiscal week of year, fiscal week start date, fiscal day seq, fiscal week date, fiscal day seq, fiscal week seq, fiscal year seq, fiscal day ago date, fiscal week ago date. 

  1. Divide the day of the year by 7, and if the remainder is 0, the week number is 7, which represents Sunday. Other week numbers are remainders. 
  2. Pushing the current date backward the days of the year is the fiscal year's start date. 
  3. To get the fiscal week of year. floor((doy-1)/7). divided day of the year by 7 and remove the decimal.
  4. To get the fiscal week end date, first I get the fiscal week of the year floor((doy-1)/7), and get the current number of days from the last day of the week through (((floor((doy-1)/7))+1)*7)-doy, then returns the week end date that is the num days after the date date_add(date, num_days).


Below is a screenshot of the dashboard in Incorta.


Comments

Popular posts from this blog

How to create histogram in Incorta use bin function.

Using Github to version and manage notebooks(Jupyter notebooks)

Using Incorta and PySpark Linear Regression ML package to predict eCommerce Customer