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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
anee123
Helper I
Helper I

Need to optimize the DAX for better performance results instead of using Filter in DAX

Hi,

 

when I use Filter functions in DAX, the performance is too slow, when i remove those filters from DAX and put it in  Visual level filiter,

the performance is improved a lot. The problem with Visual level filters is that the calculation for Variance and Variance % is causing us an issue. We need this filters in DAX.  Is there someway to optimize this DAX?

 

Measure =
CALCULATE (
DISTINCTCOUNT(Test[activation_id]),
DATESBETWEEN(Test[Activation Date],date(2019,01,01), date(2019,12,31)),
FILTER(Test,Test[col1] ="ABC"),
FILter(Test,Test[col2]<> "DEF"),
filter(Test,Test[col3]<> "OTHER"))

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

Measure =
CALCULATE (
DISTINCTCOUNT(Test[activation_id]),
DATESBETWEEN(Test[Activation Date],date(2019,01,01), date(2019,12,31)),
KEEPFILTERS(Test[col1] ="ABC"),
KEEPFILTERS(Test[col2]<> "DEF"),
KEEPFILTERS(Test[col3]<> "OTHER"))

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

Measure =
CALCULATE (
DISTINCTCOUNT(Test[activation_id]),
DATESBETWEEN(Test[Activation Date],date(2019,01,01), date(2019,12,31)),
KEEPFILTERS(Test[col1] ="ABC"),
KEEPFILTERS(Test[col2]<> "DEF"),
KEEPFILTERS(Test[col3]<> "OTHER"))

Awesome, I was also thinking about keepfilters but didn't try that, I used the exact same formula and the performance is improved a lot, Thanks a lot for your quick help! Much appreciated...

AnkitKukreja
Super User
Super User

Hi @anee123 

 

Try and use them with Variables, please go through the link below for better clarity.

https://docs.microsoft.com/en-us/power-bi/guidance/dax-variables

 

Thanks,

Ankit

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Thank you, I know the concept of varaiables, is there an alternate way to use other than Filter function in dax, filter function is too slow...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.