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

SUMX FROM 2 DIFFERENT TABLES (DAX)

Hi Guys,

 

Newbie here !

 

Just wanna ask how to sumx from 2 different tables?

 

Thank you!

 

2 ACCEPTED SOLUTIONS
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

just sum them 🙂

sumxtwice = SUMX('Table1';'Table1'[Column1])+SUMX('Table2';'Table2'[Column2])

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

edhans
Super User
Super User

If you need a single SUMX for two fields in different tables, use something like the following:

 

Measure =
SUMX(
   TableName,
   TableName[Field] * RELATED(TableName2[DifferentField])
   )

The tables have to have a relationship, and this assumes you are going from the many table to the one table. For example, you are multiplying quantities in a sales fact table against the cost of goods from a product dimension table. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

8 REPLIES 8
MuradMusleh
Frequent Visitor

Total Revenue =
SUMXSales,
                Sales[Quantity_Sold] * ( RELATED Products[Unit_Price] ) - RELATED ( Products[Unit_Cost]  )   )
)
SUMX.png
trananhviet
Regular Visitor

It worked from my side.

Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

have you been able to solve the problem with the replies given?

If so, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

All the best

Jimmy

edhans
Super User
Super User

If you need a single SUMX for two fields in different tables, use something like the following:

 

Measure =
SUMX(
   TableName,
   TableName[Field] * RELATED(TableName2[DifferentField])
   )

The tables have to have a relationship, and this assumes you are going from the many table to the one table. For example, you are multiplying quantities in a sales fact table against the cost of goods from a product dimension table. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

just sum them 🙂

sumxtwice = SUMX('Table1';'Table1'[Column1])+SUMX('Table2';'Table2'[Column2])

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

What if I want to use sumx table and multiply it with another another table on row leavel. (use  first sumx as base table and multiply from another table on row leavel. ) 
sumxMultiply = SUMX('Table1';'Table1'[Column1]) * SUMX('Table2';'Table2'[Column2])
I think totla sum will be not be right.  

 

It won't be. You'd need to do it through a common dimension table

 

test measure =
SUMX(
    Products,
    RELATED( table1[field] )
        * RELATED( table2[field] )
)

 

But that won't be right unless the product table is at the right granularity. You should probably do a merge in Power Query and do the math there.

But either way, this should be a new thread. This post was marked solved over a year ago.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.

Top Solution Authors
Top Kudoed Authors