POWER BI EXERCISES▼
POWER BI EXERCISES▼
- Basic reports (10)
- Data sources (2)
- Query editor (8)
- Multiple tables (1)
- Filtering data (9)
- Drill-through filtering (1)
- Bookmarks (4)
- Charts (10)
- Other types of visualisation (1)
- Overview of maps (6)
- Calculated columns (7)
- Introduction to DAX (3)
- Creating measures in DAX (1)
- Calendars (2)
- Date functions (2)
- Roles and security (1)
- Advanced data models (4)
- Drill-through and bookmarks (3)
- Custom visuals (3)
- Parameters (5)
- Quick measures (3)
- Report themes (2)
- Power BI mobile (1)
- Power BI Templates (1)
- Tooltips (2)
Power BI | Calendars exercise | Adding new field to support reporting by thirds
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 on the relevant Wise Owl classroom training course (sadly for the moment only in the UK).
- Go into SQL Server Management Studio;
- Open the SQL file you've just unzipped (you can press CTRL + O to do this); then
- Execute this script.
This will generate the database that you'll need to use in order to do this exercise (note that the database and script are only to be used for exercises published on this website, and may not be reused or distributed in any form without the prior written permission of Wise Owl).
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.
Sadly, your company has appointed a new FD who insists that you should report in thirds, rather than quarters. The thirds should be named after his 3 pet cats:
|Truffles||January, February, March and April|
|Sprout||May, June, July and August|
|Spot||September, October, November and December|
Start by importing all of the tables from the above database into a new model. You'll need to create a relationship between the tblCalendar table and the tblPurchase table via the PurchaseDate field:
Link these two tables as shown.
Create a new calculated column in the calendar table using this logic:
- If the MonthNumber column is less than or equal to 4, return Truffles;
- Otherwise if the MonthNumber column is less than or equal to 8, return Sprout;
- Otherwise, return Spot.
Use this to show a tree diagram proving that most sales are made in third 1:
A tree diagram with data labels displayed.
Time for a new finance director? Save this as Doing things by thirds, then close it down.
I followed the instructions and made a calculated column. While creating the tree diagram, I am getting an additional blank value. I checked all the table values, however, there are no balnk values in it.
I am trying to paste the screenshot here but it is not allowing me to paste.
Calculated field formula:
ByThirds = SWITCH(True, [MonthNumber] < 5, "Truffles", [MonthNumber] < 9, "Sprout", "Spot").
I have added this in this calendar table. The values I am getting are:
Sprout - 22558
Truffles - 20763
Spot - 19611
(Blank) - 11483
Please help in resolving this issue.
We are planning on adding the facility to add images to posts at some stage soon ...
You've done everything right apart from one thing - when you created the relationship between the Purchase and Calendar tables, I suspect you linked them by the payment date not the purchase date. Because some purchases have got null values for the payment date (because they haven't yet been paid), you get nulls in the results.