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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
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.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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