Forum Discussion
DAX Query, ALL function performance issue.
- 4 years ago
The problem is you are removing the existing filters from Date, Employee and Country because of which CALCULATE never returns blank for combinations where there is no row in the Fact table and your code triggers the CROSSAPPLY (CROSSFJOIN) behaviour of DAX Engines which returns all the possible combinations of the columns in the visual/matrix, since available information here is limited you can use this:
Total Order Measure = IF ( NOT ISEMPTY ( Sales ), CALCULATE ( COUNTROWS ( VALUES ( Sales[ProductKey] ) ), OR ( Fact[OrderType] = "aaa", FactROI[OrderType] = "bbb" ), ALL ( dimDate[dimDateID] ), ALL ( dimCountry ), ALL ( dimEmployee ) ) )
The problem is you are removing the existing filters from Date, Employee and Country because of which CALCULATE never returns blank for combinations where there is no row in the Fact table and your code triggers the CROSSAPPLY (CROSSFJOIN) behaviour of DAX Engines which returns all the possible combinations of the columns in the visual/matrix, since available information here is limited you can use this:
Total Order Measure =
IF (
NOT ISEMPTY ( Sales ),
CALCULATE (
COUNTROWS ( VALUES ( Sales[ProductKey] ) ),
OR ( Fact[OrderType] = "aaa", FactROI[OrderType] = "bbb" ),
ALL ( dimDate[dimDateID] ),
ALL ( dimCountry ),
ALL ( dimEmployee )
)
)
- joepath4 years agoHelper II
Thanks AntrikshSharma that was quick reply, Tested the your suggestion working well.
Can you also look at the below post if you have some suggestion.
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dax-Query-optimization/m-p/2281488
- joepath4 years agoHelper II
AntrikshSharma After applying the NOT ISEMPTY ( Sales ) a bug is coming.below 19301, 19302 are the dimension column values, and other 2 columns are measure, and in the 3rd column where I applied the above dax.Before appying the IF( NOT( ISEMPTY(FactROI)) below is the result which is working fine, even 19302 dimension doest have value in the first column but 3rd one still showing the result.
Now after applying the IF( NOT( ISEMPTY(FactROI)) 2nd row gone.
How to fix it without impacting the result? if I remove if condition then performance is very slow.
Thanks,
- sidhaengineer2 years agoNew Member
Thanks it solved my problem