Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jmmariscal
Frequent Visitor

How to create a column with a calculation from two tables

Hi,

 

I have a table (A) with a column for a date month, and a column with a static value per each month.

On the other hand, I have a table (B) cost and date month.

 

I want to create a new calculated column as follow:

 

Column = A[staticValue]*B[cost]. 

 

Example:

 

A

02/2021 23.4

03/2021 3.5

 

B

02/2021 2500

03/2021 1400

 

CalcultatedColum:

23.4*2500

3.5*1400

 

Thank you in advance

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @jmmariscal 

you can create a relationship between the two tables using month-year column from both tables. It looks from the example you've provided that this relationship shall be one-one relationship. 
then you can use the following code to create the calculated column:

If the coulm is in table A:

Column = A[staticValue] * RELATED ( B[cost] )

if the column is in table B:

Column = B[cost] * RELATED ( A[staticValue] )

please try to create the relationship and let me know if you need any help. 

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @jmmariscal 

you can create a relationship between the two tables using month-year column from both tables. It looks from the example you've provided that this relationship shall be one-one relationship. 
then you can use the following code to create the calculated column:

If the coulm is in table A:

Column = A[staticValue] * RELATED ( B[cost] )

if the column is in table B:

Column = B[cost] * RELATED ( A[staticValue] )

please try to create the relationship and let me know if you need any help. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.