Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a dataset of >10.000 rows. They consist of stock movements of items. So receipts into the warehouse and shipments out of the warehouse.
Two days could be like this:
Date | Creditor | Debtor | Itemcode | Amount |
1-1-2022 | A | 123 | 5 | |
1-1-2022 | AA | 123 | -2 | |
1-1-2022 | B | 456 | 3 | |
2-1-2022 | AA | 123 | -2 | |
3-1-2022 | BB | 456 | -1 |
I want to create a running total that shows the current stock per row and should be calculated for every itemcode.
The result would look like this:
Date | Creditor | Debtor | Itemcode | Amount | Stock |
1-1-2022 | A | 123 | 5 | 5 | |
1-1-2022 | AA | 123 | -2 | 3 | |
1-1-2022 | B | 456 | 3 | 3 | |
2-1-2022 | AA | 123 | -2 | 1 | |
3-1-2022 | BB | 456 | -1 | 2 |
So that when I filter on one item it would show the stock movements of that item.
I tried creating an index and that works fine if I filter on one item in power query, but I want it to calculate dynamically based on a slicer.
Any help is very much appreciated. Thank you!
Solved! Go to Solution.
Your formula didn't work, it only shows the value of Aantal per transaction. I think beause there are multiple rows for one day. I edited it a bit and I think I have it working now.
formula =
CALCULATE (
SUM ( Voorraadmutaties[Aantal] ),
FILTER ( ALLSELECTED ( Voorraadmutaties ), [Index] <=MAX(Voorraadmutaties[Index]) ),
VALUES ( Voorraadmutaties[artcode])
)
Hi @JoyceW,
You can try to use the following measure formula to calculate the rolling total based on the current date and item code:
formula =
VAR currDate =
MAX ( Table[Date] )
RETURN
CALCULATE (
SUM ( Table[Amount] ),
FILTER ( ALLSELECTED ( Table ), [Date] <= currDate ),
VALUES ( Table[Itemcode] )
)
Regards,
Xiaoxin Sheng
Your formula didn't work, it only shows the value of Aantal per transaction. I think beause there are multiple rows for one day. I edited it a bit and I think I have it working now.
formula =
CALCULATE (
SUM ( Voorraadmutaties[Aantal] ),
FILTER ( ALLSELECTED ( Voorraadmutaties ), [Index] <=MAX(Voorraadmutaties[Index]) ),
VALUES ( Voorraadmutaties[artcode])
)
@JoyceW Amazing.
Exactly what I was looking for to detect when a value is over a certain amount in my case.
Very good solution, I am able to sort any column and it still keeps up with the date order and the amount in my case.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
11 | |
10 | |
9 | |
9 |