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

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

Reply
RJS849
Frequent Visitor

Calculate row data from two different tables using the filter

I have two tables. I need to get difference of Sum from filtered rows of two tables.

 

In the example below I need to sum up all incomes by department. I can easily do that by creating matrix table which displays Sum of total income by department.

What I want is the summary table below where each row in the column 'Difference' witll add up total incomes from table "Real Income' by department and subtract EstIncome value from 'Est' table for the same department.

 

I can create measure for each department using CALCULATE(SUM('Real Income'[Income), 'Real Income'[DEPTID]="101A") and subtract the value from another table for same department but that will create column for each department.

 

Real Income Est Income 
deptIncome deptEstIncome
101A10000 101A16000
102A20000 102A21000
101A15000   
     
     
Summary    
deptDifference   
101A9000   
102A-1000   
1 ACCEPTED SOLUTION
Anonymous
Not applicable

This will be come significantly easier if you create a "lookup table" that holds all the departments.

 

Then it is simply:

Total Est  := SUM('Estimates'[EstIncoming])

Total Real := SUM('Real'[Incoming])

Delta := [Total Real] - [Total Est]

 

When creating your summary table, you would place Departments out of the new lookup table on rows (which would cause both fact tables to be filtered, via the magic of the relationships you create).

 

One way to create the lookup table, is to use the "Calculate Table" on the modeling ribbon:

Departments = DISTINCT(UNION(VALUES(Real[Dept]), VALUES(Est[Dep])))

 

Don't forget to relate it back to both your fact tables.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This will be come significantly easier if you create a "lookup table" that holds all the departments.

 

Then it is simply:

Total Est  := SUM('Estimates'[EstIncoming])

Total Real := SUM('Real'[Incoming])

Delta := [Total Real] - [Total Est]

 

When creating your summary table, you would place Departments out of the new lookup table on rows (which would cause both fact tables to be filtered, via the magic of the relationships you create).

 

One way to create the lookup table, is to use the "Calculate Table" on the modeling ribbon:

Departments = DISTINCT(UNION(VALUES(Real[Dept]), VALUES(Est[Dep])))

 

Don't forget to relate it back to both your fact tables.

Thanks scottsen for the solution. That is what I wanted.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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