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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
vipett
Helper III
Helper III

DAX remaining sum after deductions

I'm trying to look at our demand going forward and the current stock levels.
For example, if we in January have 20 in demand and 50 in stock, then nothing needs to go to step two (breakdown to components) and we would have 30 left in stock. If the demand is 40 in february, then the net need (to step 2) would be 10 (30 in stock - 40 in demand), and every month after that, the entire demand would go to step two.

Important: The table I am using in Power BI is crossjoined via formulas, thus I can't do anything in PowerQuery. (If I do the crossjoin in Powerquery, the size becomes larger than 2gb for some reason..)

See sample file here what I currently do in Excel:

https://we.tl/t-agmnzYdv2W

Untitled.png

1 REPLY 1
vipett
Helper III
Helper III

I have tried this so far, but it basically just takes the demand - stock and doesn't consider if the stock was consumed previously.. (in this case I ignored the customer..)



RemainingDemand =
VAR CurrentMonth = Table[Month]
VAR CurrentProduct = Table[UnifiedItemNumber]
VAR PreviousStock =
CALCULATE (
SUM ( Table[Stock] ),
FILTER (
Table,
Table[UnifiedItemNumber] = CurrentProduct
&& Table[Month]= MAXX (
FILTER (
Table,
Table[UnifiedItemNumber] = CurrentProduct
&& Table[Month] < CurrentMonth
),
Table[Month]
)
)
)
VAR CurrentDemand = Table[Total]
RETURN
IF (
PreviousStock >= CurrentDemand,
0,
IF ( PreviousStock = 0, CurrentDemand, CurrentDemand - PreviousStock )
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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