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 of two different table

Good evening everyone

I have a question regarding SUMX. I have sales data that contain the Quantity of Sales in the Sales Table and the net price of items in the Dimension Product table. I want to calculate the total price, which is the Quantity*Net Price. Both table already related through ProductID

How to do that?

DimProduct.PNGSales Data.PNG
Thank you



1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

In the Sales Table, you may write a calculated column formula (RELAED() function) to bring over the price from the Price table.

Net price = related(Prices[Price])

In the Sales tab, you may write another calculated column formula to calculated the Revenue

Rev = Sales[Net price]*Sales[Quantity]

Now write a measure called Revenue and drag that to your visual

Revenue = sum(Sales[Rev])

Hope this helps.


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

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

In the Sales Table, you may write a calculated column formula (RELAED() function) to bring over the price from the Price table.

Net price = related(Prices[Price])

In the Sales tab, you may write another calculated column formula to calculated the Revenue

Rev = Sales[Net price]*Sales[Quantity]

Now write a measure called Revenue and drag that to your visual

Revenue = sum(Sales[Rev])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Unfortunately, the Net Price calculated column result using RELATED is the sum of price, not price of a single item

Cannot be.  RELATED() does not add.  It's like the VLOOKUP() of MS Excel.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Sorry my bad, Your solution works just fine. Thank you

You are welcome.


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

Hi @Anonymous try something like this...

SUMX(
	[Sales],
	Quantity * RELATED(Product[Price])
)

Without seeing your data model, I doubt the table and field names are correct, but the pattern should work.  Hope this helps!  🙂

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.