POWER BI EXERCISES▼
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 one of more of the courses 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.
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:
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:
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:
You can hide a table in Relationships view by right-clicking on it.
Now add two calculated columns to the towns table:
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:
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:
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:
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.