Forum Discussion
Akos9207
3 years agoFrequent Visitor
Starting stock level
Hi, I would like to ask for some help with the following problem. Sample data ItemID Stock Date ID 1 10 2022.12.12. 1 1 14 2022....
Jihwan_Kim
3 years agoSuper User
Hi,
Thank you for your feedback, and please try the below whether it shows any result and it suits your requirement.
Expected result measure: =
VAR _mindateslicer =
MIN ( 'Calendar'[Date] )
VAR _maxdatedata =
MAXX (
FILTER (
ALL ( Data ),
Data[ItemID] = MAX ( Data[ItemID] )
&& Data[Date] <= _mindateslicer
),
Data[Date]
)
VAR _maxid =
MAXX (
GROUPBY (
FILTER (
ALL ( Data ),
Data[ItemID] = MAX ( Data[ItemID] )
&& Data[Date] = _maxdatedata
),
"@maxID", MAXX ( CURRENTGROUP (), Data[ID] )
),
[@maxID]
)
RETURN
CALCULATE ( MAX ( Data[Stock] ), REMOVEFILTERS ( calendar ), Data[ID] = _maxid )
Akos9207
3 years agoFrequent Visitor
Hi,
Thanks for the reply. I tried this measure and got mixed results.
The good: For some products i got the correct result.
The bad: The calculation time is very slow with full matrix , and in some cases i didnt even get any result.
I used the TopN function to get the end stock quantity and it works great. If that could be change somehow to see record outside of the date filter, but keep other filters would be nice... if possible...