Forum Discussion

ShaunLeMouton's avatar
2 months ago
Solved

Use a table multiple time

Hi    I have a referential table with code and countries and nationalities I have a table with my users and a code for the country of the adress and a code for the nationality. How can i use my r...
  • oussamahaimoud's avatar
    2 months ago

    Hi ShaunLeMouton,

    Hope you're doing well!

     

    So yes, duplicating a table in the semantic model is absolutely possible via a DAX calculated table, and it's the standard pattern for this exact use case.

     

    the clean solution is to create multiple inactive relationships between your user table and your referential table, then use USERELATIONSHIP in your DAX measures.

    But if you want the labels directly as columns (which is usually the case here), the better approach is to use calculated columns with RELATED + USERELATIONSHIP, except that combo doesn't work directly. So the real pattern is duplicate the referential table using a calculated table.

    In your semantic model, create a second table that's just a copy of your referential:

    Nationalities = Countries

     

    This creates a second logical table pointing to the same data. Then:

    • Create a relationship between Users[address_country_code] → Countries[code]
    • Create a second relationship between Users[nationality_code] → Nationalities[code]

    Both relationships are active, each pointing to a different logical table, so there's no ambiguity. You then just use RELATED(Countries[label]) and RELATED(Nationalities[label]) directly as calculated columns, no tricks needed.