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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
barlevitzky
Helper II
Helper II

Calculated column between two tables

Hi,

I have 2 tables: 1. Revenue - each row is a sale. 2. Costs - Each row is a cost action.

The only Connection between these two tables is the date, so I made a table like this:

Column1      Column2               Column3

Date             Sum of Revenue    Sum of Cost

 

I want to create a calculated Column4 which will be profit (Revenue - Cost), these two are coming from different tables.

Thanks in advance.

1 ACCEPTED SOLUTION

Hi @barlevitzky

 

You ought to use "Calculate". Calculate transforms ROW CONTEXT into FILTER CONTEXT

 

 

In Column2 use (Modify the table name according to your situation)

=calculate(Sum(RevenueTable[Revenue])

In Column3 use (Modify the table name according to your situation)

=calculate(Sum(CostTable[Cost])


Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
v-yuezhe-msft
Employee
Employee

@barlevitzky,

Do you have 1:1 relationship between the two tables? If so, create column4 using the DAX below. If not, please share sample data of the two tables and tell us which table have duplicate dates in Date column.

Column4 = Revenue[Column2] - RELATED(Costs[Column3])


Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, Thanks for your reply.

The connection between the tables is many to many and made by a third Table. 

When I am typing "Related.." PowerBI suggests me only columns that exist is this third table. (I need a column from the first table).

 

 

Hi @barlevitzky

 

You ought to use "Calculate". Calculate transforms ROW CONTEXT into FILTER CONTEXT

 

 

In Column2 use (Modify the table name according to your situation)

=calculate(Sum(RevenueTable[Revenue])

In Column3 use (Modify the table name according to your situation)

=calculate(Sum(CostTable[Cost])


Regards
Zubair

Please try my custom visuals

Thanks ! 

vcastello
Resolver III
Resolver III

Hi @barlevitzky

What about ....

Column4 = [Column2] - [Column3]

Hope That Helps

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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