Modifying the date table with the YEAR function
In order to make the date table easier to use in reporting, you will add new columns to the table created in the Creating a date table in Visual Studio recipe. In this recipe, you will create columns based on the date column such as year, month, and weekday.
Getting ready
Complete the steps in the Creating a date table in Visual Studio recipe.
How to do it...
Open the Model.bim to the Calc_Date_T table.
On the Add Column next to CRASH_DATE, select the first cell and enter the formula to return the year from the date:
=YEAR(Calc_Date_T[CRASH_DATE])
Once you have done this, press Enter:
How it works...
In this recipe, you added a new calculated column to the Calc_Date_T table to show the year for each record. You passed the date to the YEAR
function and it returned the 4-digit year as the output. Using this method, you can create the columns required to build a hierarchy for your uses to leverage.