Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculated Column - 2 Tables

Looking for help with a calculated column between two different tables.

 

The end goal is for the calculated column to be: (Hours at Completion) - (Travel Time)

 

Hours at Completion is on one table, Travel Time is on a different table.

 

The relationship between the two tables is Many:1.

 

How can I accomplish this? 

  • If Table 1 is on the many side, you can use this expression to get your result

     

    NewColumn = Table1[Hours at Completion] - RELATED(Table2[Travel Hours])

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

4 Replies

  • Anonymous share the sample data and expected output. Read this post to get your answer quickly.

    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

     

    Although you can try to add column in the table that is on the many sides by using DAX function called RELATED to refer column from one side.

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Table 1:

      Project CodeHours at Completion
      Project A90
      Project B80
      Project C102

       

      Table 2:

       
      Project CodeTravel Hours
      Project A5
      Project B0
      Project C4
       

       

      Desired Output: (Hours at Completion - Travel Hours)

      Project Code(Hours at Completion - Travel Hours)
      Project A85
      Project B80
      Project C98

       

       
      • mahoneypat's avatar
        mahoneypat
        Microsoft Employee

        If Table 1 is on the many side, you can use this expression to get your result

         

        NewColumn = Table1[Hours at Completion] - RELATED(Table2[Travel Hours])

         

        If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

        Regards,

        Pat