transcript

excelisfun - Excel Magic Trick 1299: Automatic Calendar Table in Data Model, New in Excel 2016

Thumbnail of the video “excelisfun - Excel Magic Trick 1299: Automatic Calendar Table in Data Model, New in Excel 2016”
Download Markdown
Community upload. AI output has not been independently verified.

Welcome to Excel Magic Trick number 1299. If you want to download this Excel workbook and follow along, click on the link below the video. I love hanging out on our online Excel team. Jazzista1967 at YouTube gave us this trick. It is simply this: in the Highline Excel 2016 series, we were building data models, and I was building the calendar table by hand. Then jazzista1967 pointed out that there is an automatic calendar table, brand new in Excel 2016.

I have already imported 800,000 rows of data. If you want to learn about PowerQuery, PowerPivot, or data modeling, there are some great resources linked. But let's go to PowerPivot and choose Manage Data Model. Here is our one fact table, with our sales, date, product, and revenue columns.

In the last video, Excel Magic Trick 1298, we saw that for a data set this small, we can just use the automatic Group By Date feature. But if you want to do more advanced DAX work, such as using the amazing time intelligence functions or quarters that are not standard, then we need a calendar table. Here is how easy it is. Go to Design, then Calendars. There is a date table option, and there it is. When I click New, it goes through this table, finds the minimum and maximum dates, and, just like in the last video, it creates a set of automatic calculated columns. Sure enough, it creates our first column with a unique list of dates, which is what a calendar table needs. It also adds Year, Month Number, Month Name, Year and Month, Day of the Week, and even the actual day name.

If your source data changes, this is beautiful. You come back to the Date Table button and choose Update Range, and it will look through your fact table again and update this table.

If you want to use these dates in a pivot table, you have to build a relationship between the two tables. So we go to Home, then over in View, I click Diagram View. Here we see something totally amazing with this calendar table. They not only created these extra helper or calculated columns, which we can drag into the row, filter, and column areas of a pivot table, but they also created a hierarchy. That is where you drag one field and it brings all four of these into the pivot table. We will see that when we create a pivot table.

We need to create a relationship between the date column in the calendar table and the dates in our sales or transaction table. This is a one-to-many relationship: the calendar table has the unique list of dates in its first column, and our sales table has many rows with those dates.

Now we can create a pivot table on a new sheet and click OK. I go to the calendar table and check it out, and there is the date hierarchy. I drag it down to Rows, and instantly we see that if we expand it, we get Year, Month, and Day. I actually do not want that. I want to go to More Fields and set Month Number down the rows, Year across the columns, and then go to our sales table and add Revenue. Whoops, not Month Number. I will uncheck that and drag Month down to Rows. We would need to tidy up the pivot table if we were going to use it, but that is the amazing automatic calendar table. I love hanging out on our online Excel team. Thanks to jazzista1967. We will see you next trick.