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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
olivere91
Helper I
Helper I

Incorrect Measure Totals

Hi, I'm having trouble with a measure giving inconsistent results:

 

Available Inventory =
SUM('items'[Inventory]) - SUM('Sales_Lines'[Quantity on SO])
 
Below is an exmaple, the top line is correct the bottom line is not. What can I do?
 
Capture.PNG
1 ACCEPTED SOLUTION

Try the following formula

Available Inventory = SUMX(VALUES ( 'items'[Item_Number] ), CALCULATE ( SUM ('items'[Inventory])))
-
SUMX(VALUES ( 'items'[Item_Number] ), CALCULATE ( SUM ('Sales_Lines'[Quantity on SO])))

 

View solution in original post

8 REPLIES 8
themistoklis
Community Champion
Community Champion

Hello @olivere91 ,

 

Are there any other fields in the table which are not displayed in the image that you sent?

Hi there, plenty of rows following the same formula. The only other colums not shown here are Item number and Item description. There is also a filter for item type category. 

Try the following formula

Available Inventory = SUMX(VALUES ( 'items'[Item_Number] ), CALCULATE ( SUM ('items'[Inventory])))
-
SUMX(VALUES ( 'items'[Item_Number] ), CALCULATE ( SUM ('Sales_Lines'[Quantity on SO])))

 

That didn't work. These are the column headers if that helps.

 

olivere91_0-1610920230747.png

 

@olivere91 

 

Change 'items'[Item_Number]  to No .. name of first field.

If you could share the file that would be even better. Mask any sensitive data

Yeah, I replaced the 'items'[Item_Number]  to No. Sorry I'm very new at this I don't know how to mask. 

I fixed it! the measure now reads:

 

Available Inventory = SUMX(VALUES ( 'items'[No] ), CALCULATE ( SUM ('items'[Inventory])))
-
SUMX(VALUES ( 'items'[No] ), CALCULATE ( SUM ('Sales_Lines'[On Open SO])))
 
 
Can you explain why my original measure wasn't working every time?

Hello @olivere91 ,

 

An article that explains the issue, is the following:

https://blog.enterprisedna.co/why-your-total-is-incorrect-key-power-bi-concept/

 

It has to do with how PowerBi read the context especially if you have filters applied.

SUMX is an iterator and it reads data row by row

Values function makes sure that every row displayed in the table will be read

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.