Forum Discussion

ATWEST's avatar
ATWEST
New Member
3 months ago
Solved

Measures breaking after switching source from DirectQuery to Import (table relationships?)

My organization has a Power BI dashboard that uses a table loading via DirectQuery. This table contains key dimensional data about our portfolio of Buildings (real estate industry). We want to switch...
  • Shai_Karmani's avatar
    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