Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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:
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.
3. Here is the simple Excel formula that achieves the desired output:
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.
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
It is for creating a new column.
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]
)
Hi,
Please check the below picture and the attached pbix file.
It is for creating a new column.
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]
)
Thank you, this worked!
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
19 | |
15 | |
7 | |
6 |