# Exercise: Group shopping centres into bands, by size

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!

 Category ==> SSAS - tabular  (29 exercises) Topic ==> The EARLIER Function  (1 exercise) Level ==> Harder than average Course ==> SSAS - Tabular Model
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.

This exercise assumes that you have a base model set up (see one of the many other SSAS tabular exercises on loading tables from the MAM database and creating a model).

Open the Word document in the above folder, and paste it into your model to create a new table:

The new table, which is here called Categories.

Create a calculated column in the Centre table to give the value of the category by using this logic:

Show the value of the CategoryName column from the Category table where this centre's number of units is less than the upper amount but also greater than or equal to the lower.

If you succeed (and there are many things which can go wrong!) you should be able to create this pivot table:

Just to ice the cake, the sizes have been sorted correctly.

If you want to keep a copy of what you've done, use DAX Editor to create a copy of your measures with extension .dax called Mind-expanding DAX, and save your workbook with the same file name.

04 Oct 17 at 10:05

This will be the solution

=CALCULATE( VALUES('unit sizes'[Category]), VALUE('unit sizes'[Lower])<=EARLIER(tblCentre[NumberUnits]), VALUE('unit sizes'[Upper])>EARLIER(tblCentre[NumberUnits]) )

04 Nov 16 at 19:56

I got the same solution as above, but with using Switch. How can I use EARLIER here ?

Andy B
07 Nov 16 at 09:36

We don't give out answers to exercises I'm afraid - there has to be some incentive to attend our courses!  However, you can see how the EARLIER function works by watching this video (it'a about Power BI for Excel, but the DAX formulae and principles are the same) or viewing this blog.