Forum Discussion
Previous Week Inventory - this week Sales
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
WINDOW function (DAX) - DAX | Microsoft Learn
expected result measure: =
VAR _startdate =
CALCULATE ( MIN ( data[week_end_date] ), REMOVEFILTERS () )
VAR _startinginventory =
CALCULATE ( SUM ( data[inventory] ), data[week_end_date] = _startdate )
VAR _previousinventorycumulate =
CALCULATE (
SUM ( data[inventory] ),
WINDOW (
1,
ABS,
-1,
REL,
ALL ( data[week_end_date] ),
ORDERBY ( data[week_end_date], ASC )
)
)
VAR _salescumulate =
CALCULATE (
SUM ( data[sales] ),
WINDOW (
2,
ABS,
0,
REL,
ALL ( data[week_end_date] ),
ORDERBY ( data[week_end_date], ASC )
)
)
RETURN
SWITCH (
TRUE (),
MAX ( data[week_end_date] ) = _startdate, _startinginventory,
_previousinventorycumulate - _salescumulate
)
Hello Jihwan_Kim,
Thanks. I think we are getting close. Instead of the first date you have inventory, I want the start inventory is based on the week of today. I have week indexing for my date table so I like to pin the start inventory is max(week index) = week index(today()). And I don't have next week inventory that will be this week invnetory - this week sales( I know I say next week but this week will work as well).
Thanks!
- Volvo_Chang2 years agoHelper I
Below is a screenshot of my dataset. supplier inventory QOH row 53 = supplier inventory QOH row 52 + forecasted prodcution row 53 - baseline row 53.
supplier inventory QOH row 54 = supplier inventory QOH row 53 + forecasted prodcution row 54- baseline row 54.
- Volvo_Chang2 years agoHelper I
Hello Jihwan_Kim ,
Just like to follow up on this one. Thanks!
- Jihwan_Kim2 years agoSuper User
Hi,
Thank you for your message, and please share your sample pbix file's link, and then I can try to look into it.
- Volvo_Chang2 years agoHelper I
Hello Jihwan,
Thank you so much for reply.
Please see below with my dummy dataset and screenshot.
Basically, I like to create a measure or dax to be able to take the most recent supplier invenotry QOH from row 11 + row 12 forecast production - row 12 baseline = row 12 supplier inventory. Row 13 supplier inventory qoh = row 12 supplier invneoty 923,607(from calculation above)+ 72000-17933. and the sequence continues to the alst row.https://drive.google.com/file/d/1nSIRnbtyE_AwmjD9C2EBWanVzyuUD4Ot/view?usp=sharing