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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Oros
Post Prodigy
Post Prodigy

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?

Oros_0-1679432292090.png

 

This SHOULD be the correct result

Oros_1-1679432522737.png

 

But I am getting this

Oros_2-1679432552376.png

Maybe because of the context of my subtraction measure (7-5)

Oros_3-1679432604231.png

 

 

 

 

 

 

1 ACCEPTED SOLUTION
bolfri
Solution Sage
Solution 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:

 bolfri_0-1679529703816.png

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:

bolfri_1-1679529872205.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
bolfri
Solution Sage
Solution 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:

 bolfri_0-1679529703816.png

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:

bolfri_1-1679529872205.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Ahmedx
Super User
Super User

you need to replace the words ordered with something else or write _ordered

Hello @Ahmedx,

 

Thank you for your quick reply.  I tried your solution but some records don't work (inventory-ordered).  Maybe I am missing something else?  Thanks again.

 

Oros_0-1679519624985.png

 

vicky_
Super User
Super User

Inventory to fill = 
var inventory = CALCULATE(SUM([Inventory]), REMOVEFILTERS([Order#])) 
var ordered = CALCULATE(SUM([Ordered]), REMOVEFILTERS([Order#]))

return inventory - ordered

Hi @vicky_ ,

 

Thank you very much for your quick reply.  Maybe there is a minor syntax that is missing.  I get this error:

 

Oros_0-1679486959765.png

 

Thanks again.

Helpful resources

Announcements
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.