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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
a__miller
Frequent Visitor

3 Calculated Columns - Values in different rows

 

Hi, I'm struggling to know where to start with these 3 calculated columns. I attached an excel with 3 yellow columns that I'm trying to replicate in power bi, but I don't know what DAX I can use to create the correct calculated columns.

 

Is there a way to calculate the 3 column quantities for each category? I'm looking to see what order quantity can be filled based on the next inventory quantity coming in, what will be short, and the remaining inventory once the order is filled. Thank you in advance!

 

Here's a snapshot of excel.

 

a__miller_1-1646925389746.png

 

here's a copy of the table

 

CategoryDateIncoming InventoryOrderFilled Order quantityOrder Shortage QuantityRemaining Inventory
A3/1/2022     
A3/2/2022     
A3/3/2022 500 500 
A3/4/20221000 5000500
A3/5/2022     
A3/6/2022     
A3/7/2022 10005005000
A3/8/2022     
A3/9/20222000 50001500
A3/10/2022     
A3/11/2022 200015005000
A3/12/2022     
A3/13/2022     
A3/14/20221500 50001000
A3/15/2022 3003000700
A3/16/2022     
B3/1/2022     
B3/2/2022 625 625 
B3/3/20221250 625 625
B3/4/2022     
B3/5/2022     
B3/6/2022 1250625625 
B3/7/2022     
B3/8/20222500 625 1875
B3/9/2022     
B3/10/2022 25001875625 
B3/11/2022     
B3/12/2022     
B3/13/20221875 625 1250
B3/14/2022 375375 875
B3/15/2022     
B3/16/2022     

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @a__miller ,

 

You can try the following formula: if the result is positive, it means the remaining stock is sufficient; if the result is negative, it means the stock is insufficient and needs to be replenished.

M =
CALCULATE (
    SUM ( 'Table'[Remaining Inventory] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )
)
    - CALCULATE (
        SUM ( 'Table'[Order Shortage Quantity] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )
    )

vhenrykmstf_0-1647244076350.png

 

If the problem is still not resolved, please provide detailed error information and desired results screenshot. Looking forward to your reply.


Best Regards,
Henry


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-henryk-mstf
Community Support
Community Support

Hi @a__miller ,

 

You can try the following formula: if the result is positive, it means the remaining stock is sufficient; if the result is negative, it means the stock is insufficient and needs to be replenished.

M =
CALCULATE (
    SUM ( 'Table'[Remaining Inventory] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )
)
    - CALCULATE (
        SUM ( 'Table'[Order Shortage Quantity] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Category] = MAX ( 'Table'[Category] ) )
    )

vhenrykmstf_0-1647244076350.png

 

If the problem is still not resolved, please provide detailed error information and desired results screenshot. Looking forward to your reply.


Best Regards,
Henry


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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.