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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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

Click here to schedule a short Teams meeting to discuss your question.

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

Click here to schedule a short Teams meeting to discuss your question.

Thank you, this worked!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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