POWER BI EXERCISES▼
DAX | Calendars and dates exercise | Use date functions to report on marine sightings year on year
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
You can learn how to do this exercise if you attend one of more of the courses listed below!
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Open the Power BI file in the above folder:
The file contains sightings of certain marine animals in 2015-16. You can choose species in the slicer and see a summary of sightings, but we want to be able to analyse the sightings in more detail.
Load the calendar from the same folder into your model:
The Power BI option to load data from Excel.
To make this work:
- Create a relationship between the calendar date key and the sighting Date column.
- Make the calendar table a date table.
- Choose to sort the calendar months by the MonthNumber column.
Look on the Modeling of the Power BI ribbon tab for the last two options.
Now create a matrix summarising sightings by year and month:
The field well for your matrix should look like this. Be careful to tell Power BI not to sum the years, otherwise it will just add them together!
You can now expand this to show the months too:
Click on this tool to show the months too. The figures are for Harbour Porpoise sightings.
Use the PREVIOUSMONTH function to create a measure called Previous month to show sightings for the previous month:
This measure displays total Harbour porpoise sightings in the previous month.
Now use the DATEADD function to create a measure called Two months ago which shows sightings two months previously:
We're still looking at Harbour porpoise sightings. Not sure whether this reveals anything, apart from the fact that you have got the hang of time intelligence functions in DAX!
Save this file as Marine trends, then close it down.