Forum Discussion
olivere91
5 years agoHelper 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 c...
- 5 years ago
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])))
olivere91
5 years agoHelper I
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?
themistoklis
5 years agoCommunity Champion
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