557 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls 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
Creating reports in Power BI with dynamic measures or dynamic dimensions
Part two of a three-part series of blogs
This blog shows how to create fully dynamic reports, whereby users can choose which statistics to show and which dimensions to report them by.
This is much the easier of the two problems, although it does require a working knowledge of DAX.
The first thing to do is to create a slicer allowing you to choose a measure. Here in outline is how to do this. First create a new table:
Click on the Enter Data tool to create a table.
Type in a table name, column name and values such that when you finish you have a table of all the statistics that you might want to show:
The final table of measures, when you've finished creating it.
The next step is to create a slicer based on this table:
A suggested slicer, allowing you to choose one measure to display.
Note that one problem with the standard Power BI slicer is that a user can select more than one measure (or no measures at all). One way to get round is to use the Chiclet Slicer custom visual, which lets you force a user to select one (and one only) item.
Now create a measure which allows you to show a suitable title:
Title = IF(
// if someone has chosen exactly one measure ...
// ... display its value ...
// ... otherwise show an error message
"You must choose one measure"
You can now create a card and set this to display the value of your measure:
The card now displays the name of whichever measure you selected.
The final bit of magic is to create a measure which displays a different statistic according to the measure you selected in the slicer:
Measure to show = IF(
// if someone chose a single measure ...
// test its value (ie what user chose)
// if it's "Total sales", display the sum of sales
"Total sales", SUM(SalesData[Sales]),
// if it's "Average price", show the average sales
"Average price", AVERAGE(SalesData[Sales]),
// if it's "Number of sales", count the sales rows
"Number of sales", COUNT(SalesData[Id])
Now select your table (or any other visual):
We want this table to show the statistic we've chosen.
You can then use this visual to display the measure you've created:
Choose to display your measure in the table.
And as they (used to) say in the UK, Bob's your uncle!
|Parts of this blog|
25 Aytoun Street