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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join 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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.