Saturday, June 7, 2025

How to display values of a Selected Field in the Slicer using Field Parameters in Power BI

How to display values of a Default Field in the Slicer using Field Parameters in Power BI
Scenario:
When a Field is selected from Field Parameter Slicer, then we want to display the values of that Selected Field in the Slicer.
Example: 
When a [Product] dimension is selected then we want to display the values of that dimension {Radio, Fridge, Television etc}.

When no Dimension is selected then we want to display the values of the first Dimension in the Field Parameters.
Example: 
Say [Month-Year] is the first dimension in the Field Parameters list, then we want to display the values of that dimension {Jan-2024, Feb-2024, March-2024 etc}.

We can achieve this Scenario, as explained below.

1) Create a Field Parameters with a list of Dimensions:
First, we need to create a Field Parameters table with required Dimensions as per below.

fp_Dim_Selector = {
    ("Month-Year", NAMEOF('dim_Calendar'[Month_Year]), 1,"Month_Year"),
    ("Region", NAMEOF('dim_Region'[Region_Name]), 2,"Region_Name"),
    ("Country", NAMEOF('dim_Country'[Country_Name]), 3,"Country_Name"),
    ("Customer", NAMEOF('dim_Customer'[Customer_Name]), 4,"Customer_Name"),
    ("Product", NAMEOF('dim_Products'[Product_Name]), 5,"Product_Name")
}


2) Create the Slicers for Dimension and Its Values:
We can create the "Dimension" Slicer using Field_Name as Source.


Next we can create the "Dimension Details" Slicer using Field_Name and enabling the option to "Show values of selected field" by right clicking on Field_Name.



In general, the Details Slicer will show values of the Selected Dimension. However, when No Dimension is selected from Dimension Slicer, then the Details Slicer will fail to show the values, as there is no Dimension Selected, as shown below:




Instead of showing Error, by default we want to display the values of first Dimension Month-Year {Jan-2024, Feb-2024, March-2024 etc}.

This can be achieved as explained in the next step.

3) By default, display the Values of first Dimension:
To achieve this, we can create a below Measure to capture the Minimum Index Number of the Dimension.

Selected Min Dim Index =
VAR _Dim_Index = {1,2,3,4,5}
VAR _Min_Dim_Index =
CALCULATE(MIN(fp_Dim_Selector[Field_Index]),
    fp_Dim_Selector[Field_Index] IN _Dim_Index
    )
RETURN
_Min_Dim_Index

Next, we need to use this Measure as a Visual Level filter for Details Slicer, using Top N and Bottom 1 filter method as shown below:


Result:

--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. If you wish, please share your genuine Feedback or comments only related to this Blog Posts. It is my humble request that, please do not post any Spam comments or Advertising kind of comments, which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose we have a sample Sales data, which is stored with Monthly Snapsh...

Popular Posts from this Blog