Field Parameters are a useful feature of Power BI if you want to have features on your dashboard that can quickly change between different fields. The most obvious way to see this is to have a measure switcher on the axes of a chart, but there are a few different uses:
- Chart axes switcher
- Legend switcher (change the colors of a stacked bar, etc.)
- Used in Calculations
In this Blog I’ll run through how to set them up, some potential use cases and some limitations.
Setup:
1. Make sure that you have Field Parameters enabled on your version of Power BI (PBI). To do this open PBI, go to File>Options and Settings>Options and click on the Preview Features tab. From here you need to ensure that the Field Parameters box is checked. If you are checking it you will need to restart the program in order for it to work (save your work!).
2. Select the modelling ribbon and click on new parameter, and on the dropdown that appears select ‘Field’.
3. A pop-up will appear. Here you can select all of the fields that you want to appear in your Parameter, as well as renaming it.
4. Here I have selected Customer name, Country/Region and Manufacturer as the fields I want in my Parameter. Note that the ‘Add slicer to this page’ is selected, so that when I click create a slicker for the parameter will automatically be added to the page.
a. In order to add a numeric field to the parameter you will first need to create it in a new measure with a defined aggregation – the parameter will not accept implicit fields.
b. Once you’ve created a new field, i.e. sum(Profit) then you can add these to a parameter.
5. Once the parameter is created it will appear like a field in the right hand side pane. It will be listed under its own table named the same as the parameter.
6. You can then add the parameter to the chart like you normally would a field.
7. This field will then be modifiable by the slicer created for the parameter, allowing you to change axes dynamically.
Limitations:
- There is no editing window for the parameter. In order to add/remove fields or reorder them you need to edit the calculation. To reorder the options you can change the number that follows the field in the calculation. 0 will appear as the first one, and each number higher will be the following option.
- As mentioned above, the parameter cannot take implicit fields. In order to add numeric fields you need to create a field using them with a defined aggregation, e.g. sum(sales).
- When using the parameter to change axes in the chart all sort and drill settings are lost as you’ve changed the field the values are computed against.
- Before you select one option in the parameter it will automatically select all values – this will confuse the charts it is currently displayed on. In order to change this you need to enable single select in the options of the slicer.
Use Cases:
- The field Parameter is very useful in select situations. If you want a very flexible and dynamic chart, the Field Parameter may be your best friend. It is also very useful for dynamic titles in order to change the title to the current field being displayed.
- Overall it is a very flexible feature, and as it is able to be used in calculations there are almost endless possibilities for what it is able to be used for as long as you want to compare different fields.