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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculated column sum of values in another table

I have two related tables

Table1

IDVALUE
11900
250000
31000

Table2

IDQUANTITY
14
15
12
212
21
156
22

 I'm looking to create a calculated column (a measure won't do) in Table 1 to show the sum of quantity from Table 2, for each of the IDs.
Please help

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below.

 

Picture1.png

 

Qty CC =
CALCULATE( SUM(Table2[QUANTITY]))

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below.

 

Picture1.png

 

Qty CC =
CALCULATE( SUM(Table2[QUANTITY]))

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

works like a charm 🙂 Thansk !

Fowmy
Super User
Super User

@Anonymous 

Add the following column:

qty table2 = 
var __ table1[id] return
CALCULATE(
    SUM(Table2[quantity]),
    Table2[id] = table1[id]
) 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks for the reply. I get this error when applying your dax:
The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression.

Also, what is the variable for?

amitchandak
Super User
Super User

@Anonymous ,

new column in table 1

 

sumx(relatedtable(Table2), Table2[Qty])

or

sumx(filter(Table2, Table2[ID] = Table1[ID]), Table2[Qty])

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.