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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
wparker5932
Frequent Visitor

Calculate the difference between the value in one table and the sum of values in another table

I have two tables. One table has many costs associated with one project and the other table has the revenue for the same project.  I want to calculate the profit (Revenue-Cost=Profit). 

 

Table 1 contains four columns: Employee, Project, Hours, Cost

Table 2 contains two columns: Project, Revenue

 

I am trying to create a New Column within Table 2 named Profit.  Both tables are joined by Project name.  Table 1 will have many entries (cost) for a single project name.  Table 2 will have only one entry (revenue) for a single project name.   Within the New Column in Table 2 I want to subtract the SUM of all Costs for a single Project in Table 1 from the Revenue for the matching Project in Table 2.

 

I'm just starting to work with Power BI and I'm not finding the DAX commands or format to help me.

 

Thank you.

1 ACCEPTED SOLUTION

My bad.  I didn't properly understand your reply at first but after watching a video on DAX Functions I saw that I was not selecting "New Measure" to create the calculation.  It works now.  Thank you so much for your help.

View solution in original post

3 REPLIES 3
Sean
Community Champion
Community Champion

So create a Table Visualization

 

Place Project from Table 2 in this Table (I guess the 2 tables are related by the Project column and table2 has the unique values)

 

Create a Profit MEASURE = SUM ( Table2[Revenue] ) - SUM ( Table1[Cost] )

 

The way you describe the 2 tables that's all you need!

 

Good Luck! Smiley Happy

Getting closer.

 

But I need to match the single Revenue value (by Project) within the Revenue table to the SUM of the Costs (by Project) in the Cost table.

 

So how do I identify the single project?  In the equation you provided the value of the Profit MEASURE never changes, regardless of the Projects I select.

 

In the screen shot below, the answer to ARK-AUI should be $5,356.  There is a single vaalue for revenue and multiple values for cost.

 

PowerBI-Calc_Diff-WParker.jpg

My bad.  I didn't properly understand your reply at first but after watching a video on DAX Functions I saw that I was not selecting "New Measure" to create the calculation.  It works now.  Thank you so much for your help.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors