Forum Discussion

ifenek's avatar
ifenek
Frequent Visitor
4 years ago
Solved

Projected stock calculation help request

Hello, 

 

I need help, I'm trying to implement a stock projection calculation in place. 

What I'm looking to do is to say if I have enough stock to despatch a product. For that i'm looking at previous orders for the same product. If the due date of the despatch is the same the idea is to look at the earliest activationdate to determine an order. 

I have a column showing the available stock for the particular product. This value should be decreasing in regards of the previous orders and not stay the same like it is right now. 

 

I've attached a sample file as well as an excel spreadsheet with the calculation I'd like to achieve 

 

https://we.tl/t-g9aFPxZqwt

 

statusduedateActivationdatetraderidsorderitemnumberpartidremaingquantityavailableforassemblyCalculationResultDespatch?
ACTIVE01/10/20212021-09-30 08:11:00.000CUST1S-00017SRP1241001000/1000Ok
ACTIVE02/10/20212021-09-30 08:12:00.000CUST3S-000215SRP12420010001000-100-300600Ok
ACTIVE03/10/20212021-09-30 08:23:00.001CUST2S-00031SRP124105010001000-100-200-300400Nok
ACTIVE04/10/20212021-09-30 10:12:00.001CUST1S-00041SRP12415010001000-100-200-1050-300-650Nok
ACTIVE01/10/20212021-09-30 10:23:00.002CUST1S-00053SRP12430010001000-100900Ok

 

  • Hi, ifenek 

     

    Try to create a measure like this:

    _Result = 
    var _max=MAX ( 'Table'[availableforassembly] )
    var _count=
            CALCULATE (
            DISTINCTCOUNT ( 'Table'[Activationdate] ),
            ALLEXCEPT ( 'Table', 'Table'[duedate] )
        )
    var duedate=
        CALCULATE (
                SUM ( 'Table'[remaingquantity] ),
                FILTER ( ALL ( 'Table' ), 'Table'[duedate] < MAX ( 'Table'[duedate] ) )
            )
    var duedate_Act=
        CALCULATE (
                SUM ( 'Table'[remaingquantity] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[duedate] = MAX ( 'Table'[duedate] )
                        && 'Table'[Activationdate] < MAX ( 'Table'[Activationdate] )
                )
            )
    return 
    IF(_count>1,_max-duedate-duedate_Act,_max-duedate)

    resutl:

    Please refer to the attachment below for details. Hope this helps.

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Hi, ifenek 

     

    Try to create a measure like this:

    _Result = 
    var _max=MAX ( 'Table'[availableforassembly] )
    var _count=
            CALCULATE (
            DISTINCTCOUNT ( 'Table'[Activationdate] ),
            ALLEXCEPT ( 'Table', 'Table'[duedate] )
        )
    var duedate=
        CALCULATE (
                SUM ( 'Table'[remaingquantity] ),
                FILTER ( ALL ( 'Table' ), 'Table'[duedate] < MAX ( 'Table'[duedate] ) )
            )
    var duedate_Act=
        CALCULATE (
                SUM ( 'Table'[remaingquantity] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[duedate] = MAX ( 'Table'[duedate] )
                        && 'Table'[Activationdate] < MAX ( 'Table'[Activationdate] )
                )
            )
    return 
    IF(_count>1,_max-duedate-duedate_Act,_max-duedate)

    resutl:

    Please refer to the attachment below for details. Hope this helps.

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.