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
erhang
Helper II
Helper II

Distribution Calculating

Hi Power BI Masters ;

 

İ need your help about calculating below issue  pls 

 

i have two tables as below 

 Capture16.JPG

 

As you see i have delivery dates with different quantities.İ just want to distrubute the stock quantities (Table2)  based on delivery dates.

and if the delivery date is same for each some products ,  i want that system will check document number and will give the stock firstly the product which document number is smaller .But system will never care document number if the delivery times are different while distrubuting.

 

after calculating i want a new column which in stocks are distributed as below 

Capture18.JPG

 

 

 

 

 

 

 

 

thanks for your supports 

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@erhang,

 

You may try using ISONORAFTER Function.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
erhang
Helper II
Helper II

one of master gave me below measure to solve , but this formula is not working when the  "requested delivery day " same ... and i can not reach him 😞

 

 So i want to put a condition like that " if the requested delivery day is same , go and check document number and give the stock to smallest document number" 

 

maybe below measure makes your help easier .

 

 

Distributed Stocks =
VAR stock_to_distirubute =
    CALCULATE (
        SUM ( Table2[Stock Qty] ),
        CROSSFILTER ( Table2[Product], Table1[Product], BOTH )
    )
VAR Cumulativestock =
    CALCULATE (
        SUM ( Table1[Requested Qty] ),
        FILTER (
            ALLEXCEPT ( Table1, Table1[Product] ),
            Table1[Rquested Delivery Date]
                <= SELECTEDVALUE ( Table1[Rquested Delivery Date] )
        )
    )
VAR myqty =
    IF (
        Cumulativestock > stock_to_distirubute,
        SELECTEDVALUE ( Table1[Requested Qty] )
            - ( Cumulativestock - stock_to_distirubute ),
        SELECTEDVALUE ( Table1[Requested Qty] )
    )
RETURN
    IF ( myqty < 0, 0, myqty )

 

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.