March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Dear all,
I have been struggling with a caculation for a few days, but cannot find a way to get around the circular dependency error.
Purchase | Sale | Age | Corrected Stock at the begining of each week (Inc. Discard) | |||||
1w | 2w | 3w | 4w | 5w | 6w (Discard) | |||
2000 | 250 | 2000 | 0 | 0 | 0 | 0 | 0 | 2000 |
550 | 0 | 1750 | 0 | 0 | 0 | 0 | 1750 | |
500 | 0 | 0 | 1200 | 0 | 0 | 0 | 1200 | |
1750 | 250 | 1750 | 0 | 0 | 700 | 0 | 0 | 2450 |
250 | 0 | 1750 | 0 | 0 | 450 | 0 | 2200 | |
775 | 0 | 0 | 1750 | 0 | 0 | 200 | 1950 | |
1750 | 350 | 1750 | 0 | 0 | 975 | 0 | 0 | 2725 |
3500 | 75 | 3500 | 1750 | 0 | 0 | 625 | 0 | 5875 |
900 | 0 | 3500 | 1750 | 0 | 0 | 550 | 5800 | |
1500 | 450 | 1500 | 0 | 3500 | 850 | 0 | 0 | 5850 |
1325 | 0 | 1500 | 0 | 3500 | 400 | 0 | 5400 | |
3000 | 150 | 3000 | 0 | 1500 | 0 | 2575 | 0 | 7075 |
2750 | 625 | 2750 | 3000 | 0 | 1500 | 0 | 2425 | 9675 |
5000 | 1175 | 5000 | 2750 | 3000 | 0 | 875 | 0 | 11625 |
3500 | 2825 | 3500 | 5000 | 2750 | 2700 | 0 | 0 | 13950 |
Here is a example of aging buckets I created in Excel, based on four assumptions
1. Before simulation we have the values in first row, start with 2000 in 1 week aging bucket.
2. The aging bucket display number of stock at the begining of each week.
3. First in first out
4. Any item older than 6 weeks will be discarded, therefore in the next week unused item in week 6 will be zero.
In Excel it's easy to caculate remaining units from last week for deduction, but in PowerBI caculated column I keep getting circular dependency error, as I try to sumx previous values. Any suggestions on how to solve this problem?
@daowei To avoid circular dependency errors in Power BI when calculating inventory aging buckets with FIFO, you can use measures instead of calculated columns.
Ensure you have a table with your purchase and sale data, including the week number.
Calculate the total purchases for each week.
Proud to be a Super User! |
|
Hello bhanu_gautam,
I've tried to create measures with your methods, but Powerbi report a circular dependency between [stock at end of week] and [stock at beginning of week] again...
@daowei ,
Stock at Beginning of Week =
VAR CurrentWeek = MAX('Inventory'[Week])
VAR PreviousWeekStock =
CALCULATE(
SUMX(
FILTER(
'Inventory',
'Inventory'[Week] = CurrentWeek - 1
),
[Total Purchases] - [Total Sales]
)
)
RETURN
IF(
ISBLANK(PreviousWeekStock),
[Total Purchases],
PreviousWeekStock
)
and DAX
Stock at End of Week =
VAR CurrentWeek = MAX('Inventory'[Week])
RETURN
CALCULATE(
[Stock at Beginning of Week] + [Total Purchases] - [Total Sales],
FILTER(
'Inventory',
'Inventory'[Week] = CurrentWeek
)
)
Proud to be a Super User! |
|
Hello bhanu_gautam, thank you for your reply, but the result is still a bit far from my expectation.
Maybe my previous description was not so clear. Here is the final table I'd like to get The remaining Purchase amount from current week goes to AGE WEEK1 bucket, that's easy. Then in next week, all remaining amount from AGE Week 1 goes to AGE WEEK 2 bucket etc.
If a bucket has less than the remaining amount for sale for that week, then 0.
The consumption starts from the oldest AGE bucket (week 6), if amount insufficent, then move to age bucket week 5 etc.
So how do I offset previous remaining amount into next age bucket and 'loop' this for six times.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |