Forum Discussion
Fact table filtering dim table
- 2 years ago
The difference lies in the DAX queries Power BI generates for the different visuals.
1. When no measure is included in the visual (as in V2/V3), a "hidden measure" is automatically added to the query within SUMMARIZECOLUMNS, in this case with this expression (wrapped in CALCULATE):
COUNTROWS ( 'FactT' )This ensures that only combinations of Product/Sales values where FacT is nonempty are returned.
The DAX query also includes a check that at least one of Product/Sales is nonblank.
2. When a measure is included the visual (as in V4), the nonblank values of this measure will determine which combinations of Product/Sales values are returned. In the case of [Product_M], this measure is nonblank for all combinations in the Cartesian product of Product/Sales values.
We could summarise this as: If a table visual includes fact/dim columns but no measures, Power BI will automatically filter the combinations of fact/dim columns to those where fact is nonempty.
I extracted the essential parts of the V2/V3 & V4 queries below to illustrate:
-- V2/V3 DAX Query -- Includes rows where -- 1. CALCULATE ( COUNTROWS ( FactT ) ) is nonblank, -- which is true when FactT is nonempty when Product/Sales values are applied as filters. -- 2. At least one of DimT[Product] or FactT[Sales] is nonblank EVALUATE FILTER ( SUMMARIZECOLUMNS ( 'DimT'[Product], 'FactT'[Sales], "CountRowsFactT", CALCULATE ( COUNTROWS ( 'FactT' ) ) ), OR ( NOT ( ISBLANK ( 'DimT'[Product] ) ), NOT ( ISBLANK ( 'FactT'[Sales] ) ) ) ) -- V4 DAX Query -- Includes rows where -- 1. [Product_M] is nonblank. -- which is true for any combination of DimT[Product] & FactT[Sales] -- resulting in the Cartesian product. EVALUATE SUMMARIZECOLUMNS ( 'DimT'[Product], 'FactT'[Sales], "Product_M", 'FactT'[Product_M] )It would be interesting to understand the general rule determining what expressions are automatically added when a visual includes no measures. Presumably tables on the "end" of a chain of 1:many relationships would always be aggregated.
Regards
v3 should not show the cartesian product. The order the fields are added to the visual has no effect on the filtering because the relationship has not changed.
Adding the measure in v4 forces the model to consider every FactT row that is filtered by SalesT. Since the relationship is set to single direction, there is no filter so it is giving you the answer against every combination.
If you set the relationship to bi-directional the filtering in v4 using the measure can flow up hill.