Bring data from a different table into a calculated column in Power BI

Hello,

I have created calculated columns using column data from two separate tables before, but I recently had a problem doing it. I tried creating a calculated column Z using a simple formula of X - Y. Column X is in table 1 and then column Y is in table 2. When I created Z in table 1, it didn’t see columns from other tables. I checked if the relationship between both tables and it is still there. Any ideas about this?

Hi,

From what you are writing it is hard to grasp your intention. First of all, avoid calculated columns if you can, most of the time a measure will do the job.
Without an example, can you share a example pbi?, it is hard to tell, but a simple SUM measure of X and SUM of Y, will help to create Z (measure X - measure Y).

Paul

Enterprise%20DNA%20Expert%20-%20Small

Yes bit difficult here as I would say not all variables around this scenario are exactly known.

I’m really doubting also whether you even need a calculated column here. I rarely advise using these because you just don’t need them when writing and using DAX effectively in your models.

Here’s some examples that you could use that maybe will help but I really recommend thinking about how you can do what you need using a combination of the right data model and DAX measures.

  1. If 1:1

calculated column =

table1[X] - RELATED ( table2[Y] )

  1. If 1:many

calculated column =

oneTable[X]

- CALCULATE ( SUM ( manyTable[Y] ), ALLEXCEPT ( manyTable, Table10[linkedCol] ) ) 

Definitely look to review the below courses as soon as you can. In here are many best practices around Power BI development that are must knows early on as you get more and more into Power BI work.

This one here will be a good one for you

Thanks
Sam