Making Power BI Field Parameters Play Nice

Making Power BI Field Parameters Play Nice

In November 2023, Microsoft added a new preview feature to Power BI – Field Parameters. Since then, I have found this to be one of the most used features when creating reports. But like any new feature added to Power BI, it feels like they settled at 90% completion, with the other 10% either being too hard or out of scope for whatever reason.

In this article, I’m going to go over some of the workarounds to get the other 10% we all need.

Creating field parameters

This is pretty easy to achieve. From the Modelling ribbon select New parameter then Fields and choose the fields you want from the UI.

Create field parameters in Power BI by selecting Modelling -> Fields from the UI


You can select from measures and columns or any combination of the 2 if you really want to be daring. Note that if you want to dynamically show a measure, you do need to use implicitly calculated measures as I have done below. Selecting a Numeric field won’t automatically aggregate as it would if you included it manually in a visual.

Select the dimensions or columns you need to include in your parameter

You’re now good to go. You can now create visuals that dynamically change depending on the users selection:

Dynamically changing measures on a Power BI Visual

Dynamically changing and filtering dimensions with field parameters

Now lets look at some more advanced uses for Field Parameters. Lets say you want to allow a user to dynamically change the dimension they can view, but also filter on that dimension to focus the visual on a particular data point.

We’ll create the field parameter as we did above, this time selecting the dimensions we want to display instead of the measures:

Select the dimensions to display in a field parameter in Power BI

Since we’ve selected the option of Add slicer to this page, Power BI will automatically create a slicer with these dimensions, as it did when we created field parameter with measures.

Dynamic dimension slicer using Power BI field parameters

We’ll now duplicate this slicer and in the field well of the duplicated slicer, right-click on the field name and select Show values of selected field

Field parameters showing a detail filter in Power BI

We can now add the field parameter to a visual to dynamically switch what the users sees in real time.

How to get the selected value of a field parameter

This is something that should be much easier than what it is. There may be cases when you want to calculate a measure based on what parameter value is selected. The typical way to do this, is to use a SWITCH / IF statement around a SELECTEDVALUE statement.

Parameter Financials Dimensions = {
    ("Product", NAMEOF('financials'[Product]), 0),
    ("Segment", NAMEOF('financials'[Segment]), 1)
}

Doing so, unfortunately leads to the following error:

You can’t use SELECTEDVALUE with a field parameter – or can you?

At first, this had me perplexed. Why couldn’t I do this? An online search didn’t explain the why, but I did find a solution that involved using relatively complex aggregations to get around it. But there is a much easier way. Create a new column like this:

Label = 'Parameter Financials Dimensions'[Parameter Financials Dimensions]

I now have a new column in my parameter table that references the dimension name. I can now use this new column in my measures without the dreaded composite key error:

SelectedParameter = 
SWITCH(SELECTEDVALUE('Parameter Financials Dimensions'[Label]),
"Product", 1, // Solve our product issues
"Segment", 2 // Solve the worlds issues
)

And best of all, no more errors!

Referencing a field parameter in a measure without the composite key error

One more advanced field parameter hack

There’s another hack I have used to get more functionality out of field parameters. I won’t go into detail of this due to my current time constraints but may revisit this sometime in the future:

Create multiple field parameter tables and join them via an overarching Reference table to allow you to update multiple visuals at once

I don’t use this very often, but I have found it useful when I need multiple dynamic values from a single user selection.

Leave a Reply

Your email address will not be published. Required fields are marked *