Forum Discussion
Measures breaking after switching source from DirectQuery to Import (table relationships?)
- 3 months ago
The behavior changed because the relationship type changed. With Building on DirectQuery and the fact in a different storage mode, Building to Monthly Sales was a limited relationship, which is executed as a SQL join at query time and does not expand the fact table to include Building. ALLEXCEPT on the fact therefore did not strip the Building filter. After switching Building to Import, the relationship is strong, the fact's expanded table now includes Building, and your ALLEXCEPT clears the Building filter along with everything else not in the keep list, which is why every Building row returns the same value.
Cleanest fix is to capture the Building selection before CALCULATE and re-apply it after ALLEXCEPT clears it:
VAR SelectedBuildings = VALUES(Building[building_id]) VAR Selected_Date = SELECTEDVALUE(V_RETAIL_SALES_DISTINCT_PERIOD_TO_POWER_BI[DATE]) RETURN CALCULATE( SUM(V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[MTH_SALES]), FILTER( ALLEXCEPT( V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI, V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[INVESTMENT_ID], V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[TENTCAT], V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[TENANT_NAME], V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[Sales Type (Friendly Format)] ), V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[DATE] = Selected_Date ), KEEPFILTERS(SelectedBuildings) )The fact-to-dim slicer behavior you noticed was the same root cause. The limited relationship being executed as a join let filtering effectively go either way. With strong single-direction relationships it will not, and turning on bi-directional cross filter in a star schema usually causes more issues than it fixes.
If this helped, a thumbs up and accepting the solution would be appreciated.
Thanks,
Shai Karmani
The behavior changed because the relationship type changed. With Building on DirectQuery and the fact in a different storage mode, Building to Monthly Sales was a limited relationship, which is executed as a SQL join at query time and does not expand the fact table to include Building. ALLEXCEPT on the fact therefore did not strip the Building filter. After switching Building to Import, the relationship is strong, the fact's expanded table now includes Building, and your ALLEXCEPT clears the Building filter along with everything else not in the keep list, which is why every Building row returns the same value.
Cleanest fix is to capture the Building selection before CALCULATE and re-apply it after ALLEXCEPT clears it:
VAR SelectedBuildings = VALUES(Building[building_id])
VAR Selected_Date = SELECTEDVALUE(V_RETAIL_SALES_DISTINCT_PERIOD_TO_POWER_BI[DATE])
RETURN
CALCULATE(
SUM(V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[MTH_SALES]),
FILTER(
ALLEXCEPT(
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI,
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[INVESTMENT_ID],
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[TENTCAT],
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[TENANT_NAME],
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[Sales Type (Friendly Format)]
),
V_RETAIL_SALES_MONTHLY_SALES_TO_POWER_BI[DATE] = Selected_Date
),
KEEPFILTERS(SelectedBuildings)
)The fact-to-dim slicer behavior you noticed was the same root cause. The limited relationship being executed as a join let filtering effectively go either way. With strong single-direction relationships it will not, and turning on bi-directional cross filter in a star schema usually causes more issues than it fixes.
If this helped, a thumbs up and accepting the solution would be appreciated.
Thanks,
Shai Karmani
Hello Shai_Karmani thank you very much for the explaination. The difference in load behavior between DirectQuery and Import makes sense to me, and explains the strange results in my model. Your suggested DAX measure changes worked perfectly in my report.