Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Setting default value in Power BI filter, if nothing is selected

Hi Experts,

 

Need your help in this.

I am using smart filter by OKviz in Power BI for a text field. 

Can we set a default value for this filter, if nothing is selected in this filter. For example, I have a Filter for Country and a Bar graph, which shows the population of each country(selected in the filter)quarterly. 

Now if we clear all the selections in the 'Country' filter, it shows the aggregated result in the Bar graph.

Is there any way to make the default selection as Country = Canada, if nothing has selected in the Country filter OR the first country in the filter list

Please advise.

 

Thanks.

1 ACCEPTED SOLUTION
itsmebvk
Continued Contributor
Continued Contributor

@Anonymous Please try following steps

 

Method 1:

 

1)Duplicate Query 1 in query editor ( Ex: Report Query), delete all columns except the columns which you want to use it as a Slicer and remove duplicates. In this example I have used Company

 

2) Create a measure for default value using following expression (Replace with your columns)

 

Measure for Default Value = IF(NOT(ISFILTERED('Slicer'[Company ])),CALCULATE(SUM(Report[Sales]),FILTER('Slicer','Slicer'[Company ]="Company A")),SUM(Report[Sales]))

3)Add Ok viz slicer to report and column which you want use for slicer

 

4)Now add newly created measure as Values in your chart. I will display some default value based on your expression. see the attached PBIX FYI. 

 

Attachment.pngT

 

Method 2: Create a measure as follows PFA PBIX

 

Measure = IF(COUNTROWS(DISTINCT(ALLSELECTED(Report[Company ])))<COUNTROWS(DISTINCT(ALL(Report[Company ]))),SUM(Report[Sales]),IF(SELECTEDVALUE(Report[Company ])="Company A",SUM(Report[Sales]),BLANK()))

 

 There could different ways too.

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

Have you solved your issue by now? If you have, could you please help mark the correct answer to finish the thread? Your contribution will be much appreciated.

 

Regards,

Jimmy Tao

v-yuta-msft
Community Support
Community Support

@Anonymous,

 

Currently there's no built-in feature in slicer chart which can support default value. However, there's workaround, about how to set a defauly value for slicer using DAX formula, you may also refer to video and simiar case below:

https://www.youtube.com/watch?v=pCgK-Ze3nhA

https://community.powerbi.com/t5/Desktop/Setting-the-Default-Value-of-a-Slicer/td-p/16442

 

Community Support Team _ Jimmy Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

itsmebvk
Continued Contributor
Continued Contributor

@Anonymous Please try following steps

 

Method 1:

 

1)Duplicate Query 1 in query editor ( Ex: Report Query), delete all columns except the columns which you want to use it as a Slicer and remove duplicates. In this example I have used Company

 

2) Create a measure for default value using following expression (Replace with your columns)

 

Measure for Default Value = IF(NOT(ISFILTERED('Slicer'[Company ])),CALCULATE(SUM(Report[Sales]),FILTER('Slicer','Slicer'[Company ]="Company A")),SUM(Report[Sales]))

3)Add Ok viz slicer to report and column which you want use for slicer

 

4)Now add newly created measure as Values in your chart. I will display some default value based on your expression. see the attached PBIX FYI. 

 

Attachment.pngT

 

Method 2: Create a measure as follows PFA PBIX

 

Measure = IF(COUNTROWS(DISTINCT(ALLSELECTED(Report[Company ])))<COUNTROWS(DISTINCT(ALL(Report[Company ]))),SUM(Report[Sales]),IF(SELECTEDVALUE(Report[Company ])="Company A",SUM(Report[Sales]),BLANK()))

 

 There could different ways too.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.