Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | DAX (59 exercises) |
Topic ==> | Variables (3 exercises) |
Level ==> | Relatively easy |
Subject ==> | Power BI training |
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.
Open the Tallest Buildings - Variables.pbix file in the folder shown above. You'll find a matrix showing a count of buildings for each country and city.
A sample of values in the matrix.
Create a new measure called Count of Buildings % of Country and declare a variable to store the count of buildings. Here's some sample code to help you:
You can make up a better name for your variable. Replace the word Expression with code which counts the rows of the Building table.
In the same measure, declare another variable which counts the number of buildings and removes the filter applied by the City field.
You can use the CALCULATE and REMOVEFILTERS functions to do this.
In the same measure, add a RETURN statement which returns the result of dividing the first variable by the second variable. Apply some formatting and display the measure in the matrix.
A sample of the results you should see.
Create a new measure called % of Old Buildings. Create the following variables in the measure:
Variable name | What it should calculate |
---|---|
CountBuildings | The count of buildings. |
CountOldBuildings | The count of buildings whose Year Opened is before 2010. |
Add a RETURN statement which divides the count of old buildings by the count of buildings. Add this measure to the matrix.
A sample of the results.
Save and close the report.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.