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 the course listed below!

Software ==> DAX  (21 exercises)
Version ==>
Topic ==> Calendars and dates  (2 exercises)
Level ==> Relatively easy
Course ==> DAX
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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:

Marine sightings

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:

Get data from Excel

The Power BI option to load data from Excel.

 

To make this work:

  1. Create a relationship between the calendar date key and the sighting Date column.
  2. Make the calendar table a date table.
  3. 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:

Matrix of sightings

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:

Expanding to show months

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:

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:

Two months ago

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.

You can unzip this file to see the answers to this exercise, although please remember this is for your personal use only.
This page has 0 threads Add post