Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ifenek
Frequent Visitor

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

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

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:

vangzhengmsft_0-1633337818975.pngvangzhengmsft_1-1633337827134.png

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.

View solution in original post

1 REPLY 1
v-angzheng-msft
Community Support
Community Support

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:

vangzhengmsft_0-1633337818975.pngvangzhengmsft_1-1633337827134.png

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.