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
daxesh
Helper I
Helper I

Is there any DAX alternative to set the default filters

Hello,

I want to set default value selected on Power Bi desktop report. I have was able to achieve this requirement in Excel through
custom Vb script.

Is there any way by which can select default value on filters or slicers on report load ?

Is there any DAX alternative to achieve above requirement in Power BI desktop?

Thanks in advance.

6 REPLIES 6
daxesh
Helper I
Helper I

Thanks for the replies.


Let me put my requirement in more specific way as per your guidance.

 

Let’s say on any report load, I want to auto select YTD for the Date filter. I have achieved this using custom VBA code with Excel – Pivot Tables/Charts, but not sure how will I achieve this for Power Views or Power BI Desktop, considering the fact that programming is not supported in power BI (correct me if I am wrong here).

 

I have understood the solution you have shared. But I think that there may be a many entities on which I might have to set default filters, and then I will be ending up creating many such filters?

Hope, I have made the things much clear now. However, please feel free to ask any further questions.

 

Thank you.

Hello Daxesh,

 

From you description it seems like you are looking for ways by which you can set filters with dynamic values. By Dynamic I mean, the value of filter is not constant.

 

E.g. By default you might want to set the date filter to TODAY() whenever the pbix file is opened. Now, as TODAY() will have a different value every day, you do not want to set the date filter to a specific value. Hence, you are looking for a way by which if today is 1-Mar-16 & the file is opened, date filter will be set to 1-Mar-16 and when the same file will be opened tomorrow, the date filter will be set to 2-Mar-16.

 

AFAIK setting default values to filters in power BI file is not supported as on date. I am not sure about the upcoming releases.

 

Hope this helps!

@daxesh - If you place a slicer on your page, select something in the slicer and save your report, when you reopen the file, your selection will be there.

 

Similarly, if you set a page filter to a certain value, it will also be saved with the report.

 

I feel like I am still not understanding something.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

There is no programmatic access to slicer or filter selections in Power BI reports. You can set a literal filter, or a static rule which will be saved with the report. As @Greg_Deckler has described above, you can utilize the modeling components of Power BI (either Power Query M or DAX) to update your data such that the literal filter selection points to a new row of data (e.g. a today flag).

Nhallquist
Helper V
Helper V

I agree with @Greg_Deckler, we need a use case or more specific example.  On that note though, there is quite a bit you can do with a compbonation of DAX formulas and Visual\Page\Report filters.  For example, you can write a DAX formula to find all the dates in the data set that are Today() and then mark them with a 1, and use that as a Visual level filter for an object that displays "Todays Orders" or something.  You can use similar formulas to create Rolling periods, teams, regions, and more.  

Greg_Deckler
Super User
Super User

It depends upon what you want to do exactly. For example, can you create a DAX custom column that compares a date in the data and returns 1 if it is TODAY() and 0 if not and then set the filter in the report to "custom column = 1". Yes. Can you use DAX to determine that the user is XYZ and not ZYX and set filters automagically based upon that. Probably not. Woudl need to know your specific use case to really help out here.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.