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
gianmarco
Helper IV
Helper IV

Sum with distinct price values

Dear All,

I have the following database:

Product NameQuantityUnitary Price
Apple20,60
Apple10,60
Orange40,80
Banana30,90
Banana20,90
Banana40,90

 

I need to visualize a report with total quantity of distinct products along with their distinct unitary price and total price.

My table should looks like the following:

Product NameQuantityUnitary PriceTotal Price
Apple30,601,80
Orange40,803,20
Banana90,908,10

 

My problem is that Power BI gives me back the sum of unitary prices per product name, just like the quantities. It is good for the latter, but I don't want it for the former.

What should I do in this case?
Thank you guys

 

1 ACCEPTED SOLUTION

@gianmarco 
This should work

Total Price = 
SUMX(
    VALUES(Table9[Product Name]),
    CALCULATE(SUM(Table9[Quantity])  * AVERAGE(Table9[Unitary Price] ))
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

8 REPLIES 8
Fowmy
Super User
Super User

@gianmarco 

How did you calculate 2.4 and it should be 3.2 ?

You create the following measure:

Total Price = SUM(Table[Quantity])  * AVERAGE(Table[Unitary Price] )

 

Fowmy_0-1624626968487.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Dear @Fowmy ,

I already did that, but the total price in bold characters is wrong. It's because I do the average of the unitary price. It must be a way for which Power BI automatically associates the unitary price to the product name so I don't need to estimate the average.

@gianmarco 

Please show me the expected results

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

The expected result should be:

Product NameQuantityUnitary PriceTotal Price
Apple30,601,80
Orange40,803,20
Banana90,908,10
Total16--- (no value)13,1

@gianmarco 
This should work

Total Price = 
SUMX(
    VALUES(Table9[Product Name]),
    CALCULATE(SUM(Table9[Quantity])  * AVERAGE(Table9[Unitary Price] ))
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

That's great... Thanks @Fowmy !

Yeah, my fault. It was a mistake. Thanks. I just corrected the table.

@gianmarco 

 

Check the solution and accept it if it works for you 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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