Forum Discussion

Olenard's avatar
Olenard
Helper III
5 years ago
Solved

Inactiv Relationship in Calculated column

Dear Power BI Community !    I am trying to feed a calculated column using an inactive relationship. The idea is have an equivalent of RELATED  between two tables that have inactiv relationship to...
  • amitchandak's avatar
    5 years ago

    Olenard , In the case of a column related, will not work with inactive relation, and use relation might not work well.

     

    You can use lookupvalue or can use a formula like this

    City Name = maxx(FILTER(geography,geography[City Id]=Sales[City Id]),geography[City])

     

    refer to this video : https://www.youtube.com/watch?v=czNHt7UXIe8

  • AlB's avatar
    5 years ago

    Anonymous 

    Of course you can change the active relationship when doing calculations in a table. For instance, if you have a simple model like:

    with the relationship inactive, you can create the calculated column:

    Res = CALCULATE(SUM(Table1[Col1]), USERELATIONSHIP(DimT[Col1],Table1[Col1]))

    on table DimT, which will work fine using the otherwise inactive relationship.

    It is true that it won't work with RELATED( ) as I suggested earlier but that has nothing to do with USERELATIONSHIP( ) but rather with CALCULATE( ). RELATED( ) requires a row context and that will be lost through context transition when using CALCULATE( ). A calc column in Table1 such as:

     New col =  CALCULATE( RELATED(DimT[Col2]) )

    with the an active relationship will not work either, precisely for that reason, while this would:

     

     New col =  RELATED( DimT[Col2] )

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers