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
ddalton
Resolver I
Resolver I

How to add new column to table based on sum of values based on unique ID

Hi,

 

I have the following tables:

 

Table 1. 

IDREFValueA
2525551000
2615601500
3005621350
3245782000
.........
.........

 

Table 2.

IndexIDValueB
1252100
2252150
3261500
4300100
5324150
6324150
.........
.........

 

The following relationship exists between Table1 and Table2:

Table1RelationshipTable2
ID1:*ID

 

I want to create a column in Table1 that, based on unique ID, is effectively:

Column = Sum(Table2[ValueB]) + Table1[ValueA])

 

Such that Table 1 would look like:

 

Table 1. 

IDREFValueANewValue
25255510001250
26156015002000
30056213501450
32457820002300
......... 
......... 

 

So far, my solution has been to create a new table:

 

 

 

Table = SUMMARIZE(Table2,Table2[ID],"ValueC",SUM(Table2[ValueB]),"ValueA",SUMMARIZE(Table1,Table1[ValueA]))

 

 

 

And then create a new column in that table:

 

 

 

Column = ('Table'[ValueC]+'Table'[ValueA])

 

 

 

 

Which gives Table3:

IDValueCValueAColumn
25225010001250
26150015002000
30010013501450
32430020002300
... ... 
... ... 

 

Then, I can just add the new Column to a table or matrix visualisation. 

 

However, instead of creating a new table first, I would prefer to simply create a new column in Table1 to the same effect in a single expression but I just can't figure out the DAX. 

1 ACCEPTED SOLUTION

@ddalton if yes, like this:

SpartaBI_0-1655378844944.png

Then this is your calc column:

Column = 'Table 1'[ValueA] + SUMX(RELATEDTABLE('Table 2'), 'Table 2'[ValueB])


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

7 REPLIES 7
SpartaBI
Community Champion
Community Champion

@ddalton Table 1 and table 2 has a 1 to many relationship bases on the ID column?

@SpartaBI Yes, I should've mentioned that. 

 

I've added the relationship to the original post but for clarity it's here too:

 

Table1RelationshipTable2
ID1:*ID

 

SpartaBI
Community Champion
Community Champion

@ddalton ok, so I already replied a sec after my other post 🙂

@ddalton if yes, like this:

SpartaBI_0-1655378844944.png

Then this is your calc column:

Column = 'Table 1'[ValueA] + SUMX(RELATEDTABLE('Table 2'), 'Table 2'[ValueB])


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

That's brilliant! Thank you. 

 

I had tried using SUMX but I wasn't entirely sure how it worked and wasn't aware of the RELATEDTABLE function. 

SpartaBI
Community Champion
Community Champion

@ddalton my pleasure 🙂
Hey, check out my showcase report - got some high level stuff there 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

Thanks. I'll check it out! 

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.