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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
epmck11
Frequent Visitor

Sum column values based on another column from second table

Hello,

 

A bit new to Power BI here, so go easy on me.

 

I have two tables, table A and table B. Table A has a lot of customer numbers and their revenue for each transaction, while table B just has the distinct customer. I want to create a second column in Table B that has the sum of all the revenue from Table A for each of those customers. How can I do this?

 

Thanks

1 ACCEPTED SOLUTION

@epmck11

 

If for some reason the tables do not have a relationship...you can use this column

 

Column =
CALCULATE (
    SUM ( TableA[Revenue] ),
    FILTER ( TableA, TableA[CustomerNo] = TableB[CustomerNo] )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Create a relationship from the Customer Name column of Table A (Revenue) to the Customer Name column of Table B (Customers).  Write this calculated column formula in Table B (Customers)

 

=SUMX(RELATEDTABLE(Revenue),[Revenue])

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Zubair_Muhammad
Community Champion
Community Champion

Hi @epmck11

 

If the 2 tables are related to each other via customer column...then you can use this calculated column

 

Column =
CALCULATE ( SUM ( TableA[Revenue] ) )

Regards
Zubair

Please try my custom visuals

@epmck11

 

If for some reason the tables do not have a relationship...you can use this column

 

Column =
CALCULATE (
    SUM ( TableA[Revenue] ),
    FILTER ( TableA, TableA[CustomerNo] = TableB[CustomerNo] )
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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