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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.