cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alex_Hasan
Helper II
Helper II

Keepfilters vs Filters

Here I have calculted two measures and they produced the same result. which one is more efficient and why? 

 

greensales.JPGgreensales filter.JPGgreensales table.JPG

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Alex_Hasan 

I would suggest you use the 1st Measure "Green Sales":

Explanation: You have effectively used KEEPFILTER here to show sales only when Green colour is visible. The most important point is, only the Product [Colour] column is used but the in the second measure, you are referring to the full Product table within the Filter function which is not efficient, also it will have the unexpected effect of expanded table. 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@Alex_Hasan 

I would suggest you use the 1st Measure "Green Sales":

Explanation: You have effectively used KEEPFILTER here to show sales only when Green colour is visible. The most important point is, only the Product [Colour] column is used but the in the second measure, you are referring to the full Product table within the Filter function which is not efficient, also it will have the unexpected effect of expanded table. 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

tamerj1
Community Champion
Community Champion

Hi @Alex_Hasan 

yes becuase the first one is actually 

KEEPFILTERS ( FILTER(*Product, 'Product' [Color] = "green' ) )

where here KEEPFILTERS does nothing 

Hi @tamerj1 , your answer seems confusing to me. Could you please elaborate? 

tamerj1
Community Champion
Community Champion

@Alex_Hasan 

Sorry for the in accurate explanation.  
CALCULATE ( [Amount], "Product' [Color] = "green" ) is actually translated into

CALCULATE ( [Amount], FILTER ( ALL ( Product), 'Product' [Color] = "green" ))

Which returns the value of green in all cells. 
this is because the filter context of each cell contains the coplete product table while when using only FILTER the filter context  in each cell contains only the related color therefore the intersection is empty except for green. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors