Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello!
So...I have 3 fact tables(Inventory, Production and Demand) and 2 dim tables (Dates and Item). Each of the fact tables has a many to one with relationship with the dim tables. I'm representing this data on a Matrix visual.
The problem is that I can't get my dax measure to not carry over negative values.
Here's is the default measure I have, and here's a screenshot to show what I want to achieve.
Beginning Inventory =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR MaxOnHandDate =
CALCULATE (
MAX ( 'Date'[Date] ),
FILTER (
ALLSELECTED ( Inventory ),
NOT ISBLANK ( Inventory[Inventory] )
)
)
VAR LastBI =
CALCULATE (
SUM ( Inventory[Inventory] ),
FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] = MaxOnHandDate )
)
VAR DatesBetweenMaxDates =
FILTER (
ALLSELECTED ( 'Date' ),
'Date'[Date] < MaxDate
&& 'Date'[Date] >= MaxOnHandDate
)
VAR Projected_BI =
CALCULATE (
LastBI + SUM ( Production[Production] ) - SUM ( Demand[Demand] ),
DatesBetweenMaxDates
)
RETURN
IF (
NOT ISBLANK ( SUM ( Inventory[Inventory] ) ),
SUM ( Inventory[Inventory] ),
Projected_BI
)
Please let me know if more information is required.
Thanks!
Hi @Live_Mace,
Thank you for reaching out to the Microsoft fabric community forum. Also, thanks to @tharunkumarRTK, @kushanNa, @krishnakanth240, for those inputs. I reproduced the scenario again, and it worked on my end. I used it as sample data and successfully implemented it.
I am also including .pbix file for your better understanding, please have a look into it.
Hope this clears it up. Let us know if you have any doubts regarding this. We will be happy to help.
Thank you for using the Microsoft Fabric Community Forum
Thanks @tharunkumarRTK that perfectly explains it.
@v-kpoloju-msft thanks for your help as well, however your solution still isn't working as expected, it's not resetting the value, it's just displaying the negatives as 0. Please can you reproduce with the entire sample data? That will give a clearer picture of what the issue is. I can't find the option to upload the pbix.
Hi @Live_Mace,
Thank you for the update.
Could you please upload your PBIX file to a secure file-sharing location (for example, OneDrive) and share a view/download link here in the thread? That would allow us to review the exact model, relationships, and measure logic and reproduce the scenario more accurately on our end.
If sharing the full file isn’t possible, alternatively you can share screenshots of the model view (relationships diagram) and the exact DAX measure currently being used. That will also help us narrow down where the behavior is differing from the expected result.
Thank you for using the Microsoft Fabric Community Forum.
@v-kpoloju-msft I've uploaded the pbix here
Please let me know if you need any more information. Thanks
Hi @Live_Mace,
Thank you for sharing the PBIX file that helped clarify the behaviour. The current measure is performing a recursive running balance, which means when the inventory becomes negative, that negative value is still being used as the starting point for the next date. This is why you’re seeing values recover from negative balances instead of resetting to zero before applying production and demand.
This requirement involves a sequential calculation where each row depends on the previously calculated result. DAX is a set-based language and does not support iterative row-by-row state logic, so it cannot reliably reset the balance before calculating the next row. The recommended approach is to compute this projection in Power Query (or the source system), where rows can be processed sequentially and the reset logic (MAX(0, PreviousInventory)) can be applied correctly. Once calculated in Power Query, the result can be used directly in the model and will display the expected behaviour in the matrix visual.
Hope that clarifies. Let us know if you have any doubts regarding this. We will be happy to help.
Thank you for using the Microsoft Fabric Community Forum.
As far as I understand, in your formula (Beginning Inventory + Production − Demand), the Beginning Inventory should reset to 0 at the first instance where the result becomes negative, and that reset value should then be reused as the Beginning Inventory for subsequent rows until the cycle repeats.
This would require the DAX expression to persist and reuse its own previously calculated result across all rows, which is not something DAX supports in measures, visual calculations, or calculated columns.
Please correct me if my understanding is incorrect.
Connect on LinkedIn
read my blogs here: techietips.co.in
|
Hi @Live_Mace
Something is not clear to me. You mentioned “not carry over negative values,” but your example screenshot shows negative values. Have I misunderstood your requirement, or am I missing something here?
Hello @kushanNa,
the "Beginning Inventory" is what I have currently, I'm trying to achieve the "Expected Beginning Inventory" that one doesn't carry over the negative values. I've attached another screenshot highlighing it.
Thanks @kushanNa However It's still not calculating correctly, we shouldn't be showing 0 in these dates:
Also in the sample data we only have inventory on 2026-02-07 and 2026-02-08.
@krishnakanth240 I tried using the max, it shows 0, but behind the scenes it's still summing up the negatives.
Here's the sample data:
| Dim_Dates | Dim_Item | Fact_Inventory | Fact_Production | Fact_Demand | ||||||||||
| 2026-02-07 | A | Item | Date | Inventory | Item | Date | Production | Item | Date | Demand | ||||
| 2026-02-08 | B | A | 2026-02-07 | 17040 | A | 2026-02-07 | 5,731 | A | 2026-02-07 | 12,537 | ||||
| 2026-02-09 | C | A | 2026-02-08 | 16781 | A | 2026-02-08 | A | 2026-02-08 | 3,160 | |||||
| 2026-02-10 | A | 2026-02-09 | A | 2026-02-09 | A | 2026-02-09 | 3,402 | |||||||
| 2026-02-11 | A | 2026-02-10 | A | 2026-02-10 | 0 | A | 2026-02-10 | 7,434 | ||||||
| 2026-02-12 | A | 2026-02-11 | A | 2026-02-11 | 0 | A | 2026-02-11 | 5,922 | ||||||
| 2026-02-13 | A | 2026-02-12 | A | 2026-02-12 | 5,198 | A | 2026-02-12 | 0 | ||||||
| 2026-02-14 | A | 2026-02-13 | A | 2026-02-13 | 0 | A | 2026-02-13 | 3,703 | ||||||
| 2026-02-15 | A | 2026-02-14 | A | 2026-02-14 | 0 | A | 2026-02-14 | 3,703 | ||||||
| 2026-02-16 | A | 2026-02-15 | A | 2026-02-15 | 0 | A | 2026-02-15 | 3,703 | ||||||
| 2026-02-17 | A | 2026-02-16 | A | 2026-02-16 | 5,202 | A | 2026-02-16 | 3,703 | ||||||
| A | 2026-02-17 | A | 2026-02-17 | 5,197 | A | 2026-02-17 | 3,703 | |||||||
| B | 2026-02-07 | 421 | B | 2026-02-07 | B | 2026-02-07 | 0 | |||||||
| B | 2026-02-08 | 858 | B | 2026-02-08 | B | 2026-02-08 | 0 | |||||||
| B | 2026-02-09 | B | 2026-02-09 | B | 2026-02-09 | 0 | ||||||||
| B | 2026-02-10 | B | 2026-02-10 | B | 2026-02-10 | 0 | ||||||||
| B | 2026-02-11 | B | 2026-02-11 | B | 2026-02-11 | 400 | ||||||||
| B | 2026-02-12 | B | 2026-02-12 | B | 2026-02-12 | 500 | ||||||||
| B | 2026-02-13 | B | 2026-02-13 | B | 2026-02-13 | 0 | ||||||||
| B | 2026-02-14 | B | 2026-02-14 | B | 2026-02-14 | 0 | ||||||||
| B | 2026-02-15 | B | 2026-02-15 | B | 2026-02-15 | 524 | ||||||||
| B | 2026-02-16 | B | 2026-02-16 | 1,000 | B | 2026-02-16 | 524 | |||||||
| B | 2026-02-17 | B | 2026-02-17 | B | 2026-02-17 | 524 | ||||||||
| C | 2026-02-07 | 349895 | C | 2026-02-07 | 31,752 | C | 2026-02-07 | 29,161 | ||||||
| C | 2026-02-08 | 362009 | C | 2026-02-08 | C | 2026-02-08 | 12,827 | |||||||
| C | 2026-02-09 | C | 2026-02-09 | C | 2026-02-09 | 12,827 | ||||||||
| C | 2026-02-10 | C | 2026-02-10 | 45,464 | C | 2026-02-10 | 17,442 | |||||||
| C | 2026-02-11 | C | 2026-02-11 | 0 | C | 2026-02-11 | 122,827 | |||||||
| C | 2026-02-12 | C | 2026-02-12 | 0 | C | 2026-02-12 | 335,811 | |||||||
| C | 2026-02-13 | C | 2026-02-13 | 31,258 | C | 2026-02-13 | 16,254 | |||||||
| C | 2026-02-14 | C | 2026-02-14 | 24,883 | C | 2026-02-14 | 18,144 | |||||||
| C | 2026-02-15 | C | 2026-02-15 | C | 2026-02-15 | 13,581 | ||||||||
| C | 2026-02-16 | C | 2026-02-16 | C | 2026-02-16 | 13,581 | ||||||||
| C | 2026-02-17 | C | 2026-02-17 | C | 2026-02-17 | 13,581 |
Hi @Live_Mace
Can you share the screenshot how it is summing up negative values. Could you please elaborate what exact output value you are looking for.
Above sample data not sufficient to work. Could you please share the sample data of individual Fact and Dim tables to work or pbix file.
Hi @Live_Mace
From the above measure, in return statement can you replace 'Projected_BI' with MAX(0, Projected_BI) and check where negative values gets replaced with 0.
Also, can you share all the Fact and Dim tables with sample data of records in text format and fields you are using into the matrix visual.
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 55 | |
| 52 | |
| 41 | |
| 16 | |
| 16 |
| User | Count |
|---|---|
| 107 | |
| 103 | |
| 40 | |
| 33 | |
| 25 |