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 )
)
)
Thanks it solved my problem