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
Hi,
Shai_Karmani Great explanation nails the root cause the limited vs strong relationship shift is exactly what broke the Building filter after switching to Import mode. His VAR SelectedBuildings fix is the cleanest approach as it keeps your original measure structure intact.
ATWEST One thing worth noting regardless of which fix you apply slicers in a star schema should ideally use dimension table columns rather than fact table columns.
If this response was helpful, please accept it as a solution and give kudos to support other community members
Hi ArwaAldoud, thank you for the additional information. Yes, I do generally use columns from the dim table for slicers - my comment above was just using fact table columns in the slicer while troubleshooting my issue. Still, it's always a good reminder on best practices, thank you!