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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
WILFR3D2K24
New Member

DAX Calculated Column Creation for Inventory Tracking

Hi everyone,

I'm currently facing some difficulty in generating a calculated column using DAX, whereas it's relatively straightforward using Excel.

 

1. Below is an image displaying a sample of the dataset I'm currently working with:Screenshot 2024-02-13 at 10.44.31 pm.png

 

 

 

 

 

 

 

 

 

 

This dataset illustrates the inventory of two products. I'm attempting to monitor the remaining units after each shipment.

 

2. The new column, named "Quantity," is what I'm aiming to create using DAX.Screenshot 2024-02-13 at 10.58.09 pm.png

 

 

 

 

 

 

 

 

 

 

3. Here is the simple Excel formula that achieves the desired output:

Screenshot 2024-02-13 at 11.06.33 pm.png

 

The logic needs to take into consideration there multiple items within Category, so it can't simply substract the shipment/ or add the stock replenishment from the above value, this is where I suspect the CategoryIndex will come in handy.

 

Ideally, I would prefer a solution in DAX. However, if it can be accomplished using M Code, I'm also open to suggestions.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1707884000744.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Quantity CC =
SUMX (
    WINDOW (
        1,
        ABS,
        0,
        REL,
        Data,
        ORDERBY ( Data[CategoryIndex], ASC, Data[Date], ASC ),
        ,
        PARTITIONBY ( Data[Category] ),
        MATCHBY ( Data[CategoryIndex], Data[Date] )
    ),
    Data[Stock Replenishment] + Data[Shipments]
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1707884000744.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Quantity CC =
SUMX (
    WINDOW (
        1,
        ABS,
        0,
        REL,
        Data,
        ORDERBY ( Data[CategoryIndex], ASC, Data[Date], ASC ),
        ,
        PARTITIONBY ( Data[Category] ),
        MATCHBY ( Data[CategoryIndex], Data[Date] )
    ),
    Data[Stock Replenishment] + Data[Shipments]
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thank you, this worked!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.