Forum Discussion

admera's avatar
admera
Frequent Visitor
2 years ago
Solved

Stock reduction based on demand

Dear All Mastah Hii everyone I don't have any idea for this measure about inventory, please help. I want to get the results from reducing stock to demand. The point is that the stock calculation wil...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,admera

    Regarding the issue you raised, my solution is as follows:

    1. First, the stock value is referenced into the main table using the calculated column:

     

    INTIStock = LOOKUPVALUE('Table Stock'[Stock],'Table Stock'[ArticleCode],'Table Demand'[ArticleCode])

     

    2.Then depending on your needs, I create the following calculated columns individually:

     

    Balance = 
    var _sum=
    SUMX(
        FILTER(ALL('Table Demand'),
        'Table Demand'[Date Demand]<=EARLIER('Table Demand'[Date Demand])&&'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])),[Demand])
    return
    [INTIStock] - _sum
    
    Stock = 
    var _date=
    MAXX(FILTER(ALL('Table Demand'),
    'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]<EARLIER('Table Demand'[Date Demand])),[Date Demand])
    var _value=
    SUMX(
        FILTER(ALL('Table Demand'),
        'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]=_date),[Balance])
    return
    IF(
        _value<>BLANK(),_value,[INTIStock])
    

     

    3.Here's my final result, which I hope meets your requirements.

    Please find the attached pbix relevant to the case.

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.