WISE OWL EXERCISES
SSAS - TABULAR EXERCISES
SSAS - tabular | Calculated columns exercise | Using COUNTROWS and RELATEDTABLE in calculated columns
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.
Create a new project and model, importing the tables tblCentreType, tblCentre and tblStore. Create a calculated column in the centre type table to show how many rows there are in the centre table for each type:
The calculated column gives the same answer for every row.
The reason the answer is the same for every centre type is that no account is being taken of the relationship between the tables. To solve this, use the RELATEDTABLE function to get:
The RELATEDTABLE function returns the centres for each centre type which match up by centre type id.
Create another calculated column giving the number of stores for each centre type:
The number of stores for each centre type.