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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.