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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
JoyceW
Helper II
Helper II

Running total mulitple rows with same date and item numbers

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:

DateCreditorDebtorItemcodeAmount
1-1-2022A 1235
1-1-2022 AA123-2
1-1-2022B 4563
2-1-2022 AA123-2
3-1-2022 BB456-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:

 

DateCreditorDebtorItemcodeAmountStock
1-1-2022A 12355
1-1-2022 AA123-23
1-1-2022B 45633
2-1-2022 AA123-21
3-1-2022 BB456-12

 

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!

1 ACCEPTED 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])
    )

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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