WISE OWL EXERCISES
SSAS - TABULAR EXERCISES
SSAS - tabular | Calculated columns exercise | Use the SWITCH function to divide transactions into bands
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.
The answer to the exercise will be included and explained if you attend the course 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.
If you haven't already done so, run the SQL script in the above folder in SQL Server Management Studio to generate a database (not for commercial use or copying) called MAM.
The aim of this exercise is to categorise staff by age using the following bands:
|Year of birth||Band|
|Before the 1960s||Has-been|
To start this slightly subjective categorisation, create a new project and model containing the transaction, pos and staff tables.
You'll need to create a relationship manually between the Pos and Staff tables at this point.
Create 3 new calculated columns in the staff table:
The staff table in id order, with the 3 new columns giving the name of each member of staff, their birth year and a verdict on their age.
Here are some notes on how to create these columns:
|StaffName||Use the & symbol to join together the first name, a space and the last name.|
|YOB||Use the YEAR function to get the year for each member of staff, given their date of birth.|
|Verdict||Either use a nested IF function based on the table at the start of this exercise, or (better) use SWITCH.|
Now use these columns to show the number of transactions for each age category:
The pivot table shows that (unsurprisingly) the post 1970 generation have processed most sales.
Save this workbook as But peak agers are still best, then close it down.