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
Anonymous
Not applicable

Subtraction between two columns from table after grouping

Hi So I have two tables As below :

Table 1

Role     Foercast

1             15

1              23

2              11

1              13

 

Table 2

 

Role   Delivered

1            10

1            12

2            10

2             1

 

My result should be a table where i sum up the Role values from each table and have difference between the forecast and Deliverd column

Role  Difference(foercast-delieverd)

1             28

2             0

 

. I tried creating two tables by DAX to sum up Roles value and then merging them based on Role but when I try to do merge I dont see the tables I have created by DAX.

Please let me know how to achieve this. Thanks

5 REPLIES 5
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

Please download my pbix file attached in previous post. It should work on you side as well. 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-qiuyu-msft
Community Support
Community Support

Hi @Anonymous,

 

You can create a measure below: 

 

Difference = var del=CALCULATE(SUM(Table2[Delivered]),FILTER(ALLSELECTED(Table2),'Table2'[Role]=MAX(Table1[Role])))
var Fore=CALCULATE(SUM(Table1[Forecast]),FILTER(ALLSELECTED(Table1),'Table1'[Role]=MAX(Table1[Role])))
return 
fore -del

q1.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mmace1
Impactful Individual
Impactful Individual

So...what he said ^

 

But alternatively - do you want the unsummarized data for some reason?  You could instead in the query, group each table by the role.   Ignore the data, I'm just highlighting where the option is in the query editor. 

 

Capture.PNG

 

Then link the two tables, and do your math via a simple related() and the substraction.  

Anonymous
Not applicable

I did this but when I go to relate, only the initial available table is seen on the Query and hence I am unable to relate

mmace1
Impactful Individual
Impactful Individual

Sorry, I'm not quite understanding. 

 

So - here's an example file where I did my idea - if this isn't correct (likely) - where is my misunderstanding? 

 

https://ufile.io/utz5p

 

Thanks, 

 

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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