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
547 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 ...
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.
|
In this blog
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 ...
HASONEVALUE(Choices[Choice]),
// ... display its value ...
VALUES(Choices[Choice]),
// ... 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 ...
HASONEVALUE(Choices[Choice]),
SWITCH(
// test its value (ie what user chose)
VALUES(Choices[Choice]),
// 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])
),
BLANK()
)
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 |
---|
|
Some other pages relevant to the above blogs include:
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.