Forum Discussion
Subtraction
Hello.
I have a simple table as follows to calculate how many to fill inventory.
If Apple has a total of 10 inventory and there is a total order of 18, then I need to fill the inventory by 8.
How do you apply make a correct measure to correctly subtract ordered from inventory?
This SHOULD be the correct result
But I am getting this
Maybe because of the context of my subtraction measure (7-5)
I don't know what do you want to achive, but...
if you want to create a new dax table with stock values then:
Inventory =
SUMMARIZE(
SampleData,
SampleData[Product],
SampleData[Inventory],
"Ordered",SUM(SampleData[Ordered]),
"Inventory to fill",SUM(SampleData[Ordered]) - SampleData[Inventory]
)
if you want to create it by measures then:Inventory measure =
SUMX(
SUMMARIZE(
SampleData,
SampleData[Inventory]
),
SampleData[Inventory]
)Ordered measure = SUM(Inventory[Ordered])
Inventory to fill = [Ordered measure] - [Inventory measure]
Result:
5 Replies
- vicky_Super User
Inventory to fill =
var inventory = CALCULATE(SUM([Inventory]), REMOVEFILTERS([Order#]))
var ordered = CALCULATE(SUM([Ordered]), REMOVEFILTERS([Order#]))return inventory - ordered
- AhmedxSuper User
you need to replace the words ordered with something else or write _ordered
- bolfriSolution Sage
I don't know what do you want to achive, but...
if you want to create a new dax table with stock values then:
Inventory =
SUMMARIZE(
SampleData,
SampleData[Product],
SampleData[Inventory],
"Ordered",SUM(SampleData[Ordered]),
"Inventory to fill",SUM(SampleData[Ordered]) - SampleData[Inventory]
)
if you want to create it by measures then:Inventory measure =
SUMX(
SUMMARIZE(
SampleData,
SampleData[Inventory]
),
SampleData[Inventory]
)Ordered measure = SUM(Inventory[Ordered])
Inventory to fill = [Ordered measure] - [Inventory measure]
Result: