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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Laska
New Member

the sum of lines containing a multiplication is incorrect.

Hello,

 

I get, I don't think so complicated problem, just not solved.

Goal: I want to calculate the total stockvalue of a warehouse.

 

I have the following data available:

 

table: article

          field: articlecode

table: stock

          field: quantity

table: purchase

          field: purchaesprice

 

By multiplying quantity x purchaseprice I get the stock value per item (articlecode). I get the total stock value by adding up all the lines per item.

The result I now get in the PowerBi report is as follows:

ArticlecodeQuantityPurchasepriceStockvalue
    
A123            25           125,00   3.125,00
B123            10             90,00      900,00
C123               9           275,00   2.475,00
Total            44           490,00 21.560,00
    
Correct     6.500,00

 

So it's totally wrong. The Total is also the multiplication of the totals of quantity and purchase price. It should be as mentioned by Correct.

 

I think it has to do with Sum and Sumx, but I'm not sure what to do.

Please advice.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi 

 

Create 2 measures as below.

 

1. Stock Value1 = sum(Stock[Quantity])*sum(Stock[PurchasePrice])

2. Stock Value = sumx(SUMMARIZE(Stock,Stock[ArticleCode],Stock[Quantity],Stock[PurchasePrice]), [Stock Value1]) 

 

Total.JPG

Please confirm if the solution works..!!

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @Laska 

 

Try this:

Stock Value =
VAR _A =
    ADDCOLUMNS(
        stock,
        "Stockvalue", SUM( stock[quantity] ) * SUM( purchase[purchaesprice] )
    )
RETURN
    SUMX( _A, [Stockvalue] )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 



Anonymous
Not applicable

Hi 

 

Create 2 measures as below.

 

1. Stock Value1 = sum(Stock[Quantity])*sum(Stock[PurchasePrice])

2. Stock Value = sumx(SUMMARIZE(Stock,Stock[ArticleCode],Stock[Quantity],Stock[PurchasePrice]), [Stock Value1]) 

 

Total.JPG

Please confirm if the solution works..!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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