SSAS - tabular | The EARLIER Function 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.

Software ==> SSAS - tabular  (30 exercises)
Version ==> SSAS 2012 and later
Topic ==> The EARLIER Function  (1 exercise)
Level ==> Harder than average
Subject ==> SSAS training
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 Make-a-Mammal database and creating a model).

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

Categories 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:

Final pivot table

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

Save your workbook as Mind-expanding, 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 2 threads Add post
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 ?

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.