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
leeh_lrems
New Member

Subtract values from columns in two tables with a filter

I have two tables, each containing "Check Number" as a key.   Table 1 (Earnings) has gross pay as a column.  Table 2 (Deductions) has all benefits costs as a column.  I'm having no luck in figuring out how to subtract deductions from earnings for each check number.  Any suggestions?

TIA - Lee

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @leeh_lrems 

If there is a relationship between, you can try the following code as a column:

Subtract = var _sumcosts=CALCULATE(SUM(Deductions[benefits costs]),RELATEDTABLE(Deductions))
return [gross pay]-_sumcosts

Output:

vxinruzhumsft_0-1673317692648.png

 

If there is no relationship between two tables, you can refer to the following link as a column:

Sub = var _sumcosts=SUMX(FILTER('Deductions',[Check Number]=EARLIER('Earnings'[Check Number])),[benefits costs])
return [gross pay]-_sumcosts

Output:

vxinruzhumsft_2-1673317841190.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @leeh_lrems 

If there is a relationship between, you can try the following code as a column:

Subtract = var _sumcosts=CALCULATE(SUM(Deductions[benefits costs]),RELATEDTABLE(Deductions))
return [gross pay]-_sumcosts

Output:

vxinruzhumsft_0-1673317692648.png

 

If there is no relationship between two tables, you can refer to the following link as a column:

Sub = var _sumcosts=SUMX(FILTER('Deductions',[Check Number]=EARLIER('Earnings'[Check Number])),[benefits costs])
return [gross pay]-_sumcosts

Output:

vxinruzhumsft_2-1673317841190.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

tc_WII
Frequent Visitor

I believe there are multiple ways to do it. I am sharing one option. Steps are given below:

 

1. Go to data modeling, and create relationship of two tables with the key

2. Go to visualization, Create a new measure

3. On the formula bar, simply write:

Net Pay = SUM(Earnings[Gross Pay]) - SUM(Deductions[Costs])

4. This will create a Measure named Net Pay (you can choose any name).

5. Create a table visualization. Choose the Check number from earnings table, and the new measure Net Pay.

 

It should work properly. Thank you 🙂

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.