Forum Discussion
Is IN short circuit?
- 8 months ago
Hi DouweMeer,
Thank you for reaching out to the Microsoft Fabric Community Forum. Also, thanks to danextian, Mauro89, amitchandak, for those input on this thread. Thanks for sharing the details about the 6.5M rows that changes the situation quite a bit.
The performance issue isn’t caused by IN vs || syntax. The slowdown happens because the logic is currently inside a calculated column, which forces Power BI to run your MINX/FILTER calls once for every row during refresh. That’s why memory usage spikes from 18 GB → 64 GB.
To resolve this, I recommend moving the logic into a measure instead. Measures only run when visuals request data and allow the storage engine to optimize filter reduction.Example pattern:
Measure = VAR A1 = CALCULATE( MIN('table'[field]), KEEPFILTERS(boolean) ) VAR A2 = CALCULATE( MIN('table'[field]), KEEPFILTERS(different_boolean) ) RETURN SWITCH( TRUE(), NOT ISBLANK(A1), "something", NOT ISBLANK(A2), "something else" )This should remove the RAM pressure and significantly improve performance.
Refer these links:
1. CALCULATE function (DAX) - DAX | Microsoft Learn
2. FILTER function (DAX) - DAX | Microsoft Learn
3. Avoid using FILTER as a filter argument in DAX - DAX | Microsoft LearnHope this clears it up. Let us know if you have any doubts regarding this. We will be happy to help.
Thank you for using the Microsoft Fabric Community Forum.
DouweMeer , OR and In should be the same, with IN as a better choice. but Calculate with Without filter has a difference , in this case it is applicable for Minx
http://dataap.org/blog/2019/04/22/difference-between-calculate-with-and-without-filter-expression/
https://youtu.be/KDcmzwgPvXQ
The link you proposes doesn't seem to work.
But you would propose
measure = calculate ( min ( field ) , filter ( 'table' , field2 IN { "A" , "B" } ) )As most effective?
- amitchandak8 months agoSuper User
DouweMeer , Depends, with filter is a better choice when it is most needed. When you want to show the same value across field2, which is the sum of two values (Only for the filter column) for all other columns and GT it will give same value , you need without filter
Calculating without FILTER is generally better for performance because it's less complex
https://learn.microsoft.com/en-us/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument