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
jatneerjat
Helper V
Helper V

Dax filter() performance

Hi,

@Greg_Deckler @Anonymous @Stachu

Could i replace below FILTER() function with some other function to improve performance

 

 

CALCULATE(DISTINCTCOUNT(vwFact[AppId])
,FILTER(vwFact,vwFact[Area]="ACQ")
,FILTER(vwDate,vwDate[Date]))

 

or could i simply write it as:

 

CALCULATE(DISTINCTCOUNT(vwFact[AppId])
,vwFact,vwFact[Area]="ACQ"
,vwDate,vwDate[Date])

 

Thanks

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi @jatneerjat,

 

There aren't any conditions. So the second filter isn't necessary. ",FILTER(vwDate,vwDate[Date]))". What's your goal? The formula is simple. Is the performance very bad?

 

 

Best Regards,
Dale

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

@v-jiascu-msft

 

Yes,the power bi reports takes a lot of time to refresh.there are many measures in my ssas server which mostly use calculate along with filter() so i want a way where i can reduce filter() function because i have read somewhere that if we use filter() more oftenly then it adds to poor performance.

 

can you help me how to optimize below 3 dax queries:

 

1).

AVERAGEX(
KEEPFILTERS(VALUES('vwFact'[UId])),
CALCULATE(DISTINCTCOUNT('vwFact'[ApplicationId]))

 

2).

could i replace MAX() from 

 

UniqueMeasure =
MAX(vwDate[CalDate])-1

 

to

 

UniqueMeasure  = 
DATESBETWEEN(vwDate[CalDate])
,LASTDATE(vwDate[CalDate])-1
,LASTDATE(vwDate[CalDate])-1)
, ALL(vwDate[CalDate])
,vwFact[Area]="Eng")

 

3).

How filters applied here,how ALL() affects the filteration here,could i replace ALL()

 

EngagementDailyUniqueTeams:= CALCULATE(DISTINCTCOUNT(vwFact[TId])
,DATESBETWEEN(vwDate[CalDate]
,LASTDATE(vwDate[CalDate])
,LASTDATE(vwDate[CalDate]))
, ALL(vwDate[CalDate])
,vwFact[Ar]="Eng"

 

 

4.)

What is ALLSELECTED() achieving here:

 

CALCULATE (DISTINCTCOUNT ( vwFact[UId] )
,FILTER ( ALLSELECTED ( vwApplication ), vwApplication [Type] = "AA" )

 

Thanks
,vwFact[Ar]="Eng"
)

Could anybody help me on this?

Hi @jatneerjat,

 

Can you post a dummy sample? AND the goals of each formula. For example, we add ALL to clear the context for a purpose. So we can't remove it directly unless it's necessary. 

 

 

Best Regards,
Dale

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

Hi @v-jiascu-msft

 

I was not able to attach excel here in forum so adding the image for sample data.

this is for the first dax query.

 

1.PNG

 

Thanks

 

Hi @jatneerjat,

 

It seems the UIDs are unique. So the average could always be 1. What's the expected result of Query 1?

 

 

Best Regards,
Dale

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

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.