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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nhch
Frequent Visitor

Measure calculated two times in filtered visuals

Hi guys,

I have this simple set up, just one table with one column and a measure:

nhch_0-1712224902918.png

top50 = IF(CALCULATE(AVERAGE(TestTable[number]), ALLSELECTED(TestTable))<MAX(TestTable[number]), "yes", "no")

if i visualize it in a table everything goes as expected:
nhch_1-1712225042943.png
it also works when i add a visual filter, correctingly updating the value
nhch_3-1712225307751.png

 

but if i remove the filter (in order to have the simplest setup) and try to filter this table direct in order to show just the rows that have "yes" in the measurement it shows me the correct rows but recalculate the measurment and so i get a different value.

nhch_2-1712225111298.png

I don't know if this is a bug or a feature, if it's the latter how can i adjust the DAX in order to not consider the filters in that visual object but keep considering the filter in other objects? 

Thank you in advance!

3 REPLIES 3
Greg_Deckler
Super User
Super User

@nhch Well, it likely has to do with your use of ALLSELECTED, perhaps one of the more complex and esoteric functions in all of DAX in terms of exactly what it considers as "selected". Will see if I can recreate and test.


@ 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...

Thank you!
It should be pretty easy to recreate, i'm on the last version, the datamodel and the formula are pretty straight forward. Tell me if i need to upload the .pbix ^-^

nhch
Frequent Visitor

@Greg_Deckler  i did a bit of debugging and there is, in fact, a double evaluetion of the measurement. First in order to filter the data and secondly to display the value. Validity of the forumula aside, isn't this a big performance issue? filtered measurements could run twice as fast if instead of re evalueting them pbi just memorize the values! 
here it is the log (sorry if the numbers are in italian ^-^):
First call:

nhch_0-1712235583777.png

Second call:

nhch_1-1712235610307.png


P.S.
This is how powerbi builds the query, you can see the double evaluation marked in red

nhch_0-1712236853012.png
Thanks

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.