Forum Discussion
Setting Default Slicer Value
- 5 years ago
Hi, Anonymous
The slicer cannot be set to the default value unless the slicer is set to single selection.
But we can make the slicer look like the default value is set through some other methods.
For example, in the following example, I exclude the product "VTT" by default and create a measure to detect the selected value of my slicer. If the slicer is not selected, the product "VTT" will be excluded by default.
We need to create a summary table to get all the products, and then use the summarized product field to create a slicer. Then create the measure above to counter the slicer's choice. This is similar to a switch, and finally we can filter on the visual to get the desired result.Here I use the official sample data: financials.xlsx
you can get it from "Try a sample data"
measure:
_Default Slicer = VAR _total = CALCULATE ( DISTINCTCOUNT ( P[Product] ), ALL ( P[Product] ) ) VAR _ProductList = SUMMARIZE ( ALLSELECTED ( P ), P[Product] ) VAR _countSelected = COUNTROWS ( _ProductList ) VAR _except_Default = { "VTT" } // we can also set a list of default selected values like: // var _selected_Default={"VTT"} // just to change the "N" to "Y". VAR _if = IF ( _countSelected < _total, IF ( MAX ( 'financials'[Product] ) IN _ProductList, "Y", "N" ), IF ( MAX ( 'financials'[Product] ) IN _except_Default, "N", "Y" ) ) RETURN _ifresult:
Please refer to the attachment below for details
In addition, you can also set default values in the filter pane, for example, set the default country to Canada.
Filtering panes is also a feasible method.
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Anonymous
The slicer cannot be set to the default value unless the slicer is set to single selection.
But we can make the slicer look like the default value is set through some other methods.
For example, in the following example, I exclude the product "VTT" by default and create a measure to detect the selected value of my slicer. If the slicer is not selected, the product "VTT" will be excluded by default.
We need to create a summary table to get all the products, and then use the summarized product field to create a slicer. Then create the measure above to counter the slicer's choice. This is similar to a switch, and finally we can filter on the visual to get the desired result.
Here I use the official sample data: financials.xlsx
you can get it from "Try a sample data"
measure:
_Default Slicer =
VAR _total =
CALCULATE ( DISTINCTCOUNT ( P[Product] ), ALL ( P[Product] ) )
VAR _ProductList =
SUMMARIZE ( ALLSELECTED ( P ), P[Product] )
VAR _countSelected =
COUNTROWS ( _ProductList )
VAR _except_Default = { "VTT" }
// we can also set a list of default selected values like:
// var _selected_Default={"VTT"}
// just to change the "N" to "Y".
VAR _if =
IF (
_countSelected < _total,
IF ( MAX ( 'financials'[Product] ) IN _ProductList, "Y", "N" ),
IF ( MAX ( 'financials'[Product] ) IN _except_Default, "N", "Y" )
)
RETURN
_if
result:
Please refer to the attachment below for details
In addition, you can also set default values in the filter pane, for example, set the default country to Canada.
Filtering panes is also a feasible method.
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.