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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
sebasplas313
New Member

Add column with sum of values based on a category

 Hi community,

I would like to know how i can add a column that has the total based on two columns. In this example i have in the first column, the name of the category, the second column the number of products and in the third, the sum of each category.

Column 1Column 2Column 3
A26
A16
A36
B510
B510

My question will be the dax or power query of how i can add this third column

 

Need help , Data help and tips , Free intermediate tutorials? 

Thanks,

Sebastian

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @sebasplas313 

 

Please check the following methods.

1. Dax
Column:

Column 3 = 
CALCULATE (
    SUM ( 'Table'[Column 2] ),
    FILTER ( 'Table', [Column 1] = EARLIER ( 'Table'[Column 1] ) )
)

vzhangti_0-1659339651420.png

 

2. Power Query

First copy the table into table2 in the power query.

vzhangti_1-1659339826746.png

vzhangti_2-1659339851356.png

Merge table2. in the original table and expand the new column.

vzhangti_3-1659339941987.png

vzhangti_4-1659340032166.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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
v-zhangti
Community Support
Community Support

Hi, @sebasplas313 

 

Please check the following methods.

1. Dax
Column:

Column 3 = 
CALCULATE (
    SUM ( 'Table'[Column 2] ),
    FILTER ( 'Table', [Column 1] = EARLIER ( 'Table'[Column 1] ) )
)

vzhangti_0-1659339651420.png

 

2. Power Query

First copy the table into table2 in the power query.

vzhangti_1-1659339826746.png

vzhangti_2-1659339851356.png

Merge table2. in the original table and expand the new column.

vzhangti_3-1659339941987.png

vzhangti_4-1659340032166.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

VahidDM
Super User
Super User

Hi @sebasplas313 

 

Try this DAX expression to add a new calculated column to your table:

 

Column 3 DAX = 
CALCULATE (
    SUM ( 'Table (2)'[Column 2] ),
    REMOVEFILTERS ( 'Table (2)'[Column 2] )
)

 

 

Output:

VahidDM_0-1658877408991.png

 

 

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.