Forum Discussion

animebuff's avatar
animebuff
Icon for Helper I rankHelper I
1 year ago
Solved

dax in drilldown works without relationship

i have write a simple dax of subtraction and division and I have a region as drilldown my requirement says to remove the relationship between dim country table and fact table so I removed it using C...
  • v-hashadapu's avatar
    1 year ago

    Hi animebuff ,Thank you for reaching out to Microsoft Fabric Community Forum.


    If the direct relationship between the dimCountry table and the fact table is removed, it will impact the filtering context, so now you see the same total for all regions.

    We can use the TREATAS function to create a virtual relationship between the dimCountry table and the fact table. This way, we can eliminate the physical relationship while keeping the correct context for the calculations.


    Sample Data:

    dimCountry Table

    fact Table

    Total Value Measure:

    Total Value =

    VAR SelectedCountries = VALUES(dimCountry[Country])

    RETURN

    CALCULATE (

        SUM(fact[Value]),

        TREATAS(SelectedCountries, fact[Country])

    )


    Set up a Matrix Visual:

     

    Sample Output:

    If this helps, please mark it ‘Accept as Solution’, so others with similar queries may find it more easily. If not, please share the details.

  • v-hashadapu's avatar
    1 year ago

    Hi animebuff , Just checking in—were you able to resolve the issue?
    If one of the replies helped, please consider marking it as "Accept as Solution" and giving a 'Kudos'. Doing so can assist other community members in finding answers more quickly.
    Thank you!