DAX | Calculated columns exercise | Combine RELATED and ISBLANK to link tables together

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 if you attend the course listed below!

Software ==> DAX  (21 exercises)
Version ==>
Topic ==> Calculated columns  (5 exercises)
Level ==> Average difficulty
Course ==> DAX
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.

Open the Power BI report in the above folder.  It contains a table showing the quadrant, region and name for each town in the imported data:

Town data

However, two rows contain blanks, possibly because the id numbers don't match up between the tables.

The aim of this exercise is to use the RELATED function to show the town and region within the quadrant table:

Table of towns

The only visible table will be Towns, and the aim is to get it to show two calculated columns (unimaginatively called Quadrant and Region) to show the quadrant and region for each town. If you're feeling ambitious, you could try doing the exercise without reading any further instructions!

 

To get this to work, first hide all of the tables apart from the town one:

Hiding table

You can hide a table in Relationships view by right-clicking on it.

Now add two calculated columns to the towns table:

Filled in blanks

The region column should show No region assigned if there is no related region in the regions table; the quadrant column should show No quadrant found similarly if there's no quadrant for a town.

Use the RELATED function to pick up columns from other tables, and the ISBLANK function to test if anything is returned.

You should now see just one table in your FIELDS section:

Towns table

The Towns table now contains for each town the corresponding region and quadrant.

 

Change the fields displayed for your visual to get the required table:

Town visual fields

You'll need to display the quadrant and region fields from the Town table, rather than from the Quadrant or Region tables.

 

This should allow you to show a list of towns with no spaces in:

Full towns list

Each town shows its region and quadrant, or No region assigned or No quadrant found as appropriate.

Save your revised file as Where is Owlton, 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 0 threads Add post