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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JaviGoldstein
New Member

FIFO question

Hi, I am trying to "assign" pending orders to batches based on FIFO.   I have 2 tables:

 

tblSKU

JaviGoldstein_0-1708708295926.png

tblPendingOrders

JaviGoldstein_1-1708708323095.png

I want to add a column to tblSKU showing pending orders.   So, with the current pending orders, tblSKU would look like this:  

JaviGoldstein_2-1708708961650.png

 

Looking for the best way to accomplish this with DAX.     Thx!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JaviGoldstein ,
Here us my test data:

vheqmsft_0-1708928302168.png

Create a calculate column

Pending Orders = 
VAR tblPO = 
    CALCULATE(
        MAX(tblPendingOrders[Amount]),
        FILTER(
            tblPendingOrders,
            tblPendingOrders[SKU] = tblSKU[SKU]
        )
    )
VAR temp_result = 
    IF(
        (tblPO-tblSKU[Balance]) >= 0,
        tblPO-tblSKU[Balance],
        0
    )
RETURN
IF(
    (temp_result - tblSKU[Balance]) > 0,
    temp_result - tblSKU[Balance],
    IF(
        tblPO > tblSKU[Balance],
        IF(
            tblSKU[Batch] = 1,
            tblSKU[Balance],
            temp_result
        ),
        temp_result
    )
)

Final output

vheqmsft_1-1708928352164.png

 

Best regards,

Albert He

 

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

4 REPLIES 4
Anonymous
Not applicable

Hi @JaviGoldstein ,
Here us my test data:

vheqmsft_0-1708928302168.png

Create a calculate column

Pending Orders = 
VAR tblPO = 
    CALCULATE(
        MAX(tblPendingOrders[Amount]),
        FILTER(
            tblPendingOrders,
            tblPendingOrders[SKU] = tblSKU[SKU]
        )
    )
VAR temp_result = 
    IF(
        (tblPO-tblSKU[Balance]) >= 0,
        tblPO-tblSKU[Balance],
        0
    )
RETURN
IF(
    (temp_result - tblSKU[Balance]) > 0,
    temp_result - tblSKU[Balance],
    IF(
        tblPO > tblSKU[Balance],
        IF(
            tblSKU[Batch] = 1,
            tblSKU[Balance],
            temp_result
        ),
        temp_result
    )
)

Final output

vheqmsft_1-1708928352164.png

 

Best regards,

Albert He

 

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

 

@Anonymous this is perfect.   THANKS!   

lbendlin
Super User
Super User

Please use a proper logistics planning tool.  Power BI has no memory and is incapable of handling material allocation tasks. Its focus is on reporting data.

not using this as a logistics solution.   Reporting only.    

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors