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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
azaterol
Helper V
Helper V

Please help for stock problem

Hello everyone,

I have given the following table. When I sort the table by date in Power BI, this comes up. The order is absolutely correct and is exactly what it is supposed to be.

I created the custom index with Power query

 

 

 

 

current situation:

ID ProductID Nr Date Quantity Art Input Output Stock accumulated Stock IndexCustomer 
123 123 1 26.04.2022 00:00:00 1 Output 0 1 -1 75 1281L 
123 123 1 26.04.2022 00:00:00 2 Output 0 2 -2 73 1282M 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 311 1284N 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 305 1286O 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 303 1287P 
1084807 123 1 27.04.2022 00:00:00 4 Output 0 4 -4 307 1285Q 
123 123 2 27.04.2022 09:15:33 100 Input 100 0 100 313 1283R 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 301 1289S 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 302 1288T 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 300 1290U 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 299 1291V 

expected situation:

ID ProductID Nr Date Quantity Art Input Output Stock accumulated Stock IndexCustomer 
123 123 1 26.04.2022 00:00:00 1 Output 0 1 -1 75 1281L 
123 123 1 26.04.2022 00:00:00 2 Output 0 2 -2 73 1282M 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 71 1284N 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 69 1286O 
123 123 1 27.04.2022 00:00:00 2 Output 0 2 -2 67 1287P 
123 123 1 27.04.2022 00:00:00 4 Output 0 4 -4 63 1285Q 
123 123 2 27.04.2022 09:15:33 100 Input 100 0 100 303 1283R 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 302 1289S 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 301 1288T 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 300 1290U 
123 123 1 28.04.2022 00:00:00 1 Output 0 1 -1 299 1291V 

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @azaterol ,

Has your problem been solved? According to your snapshot, if you want to calculate the accumulated stock based on the date and ID, as you have create a index column seams based on date, you can simply create a measure:

Accumulated Stock =
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Index] <= MAX ( 'Table'[Index] )
    ),
    [Stock]
)

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @azaterol ,

Has your problem been solved? According to your snapshot, if you want to calculate the accumulated stock based on the date and ID, as you have create a index column seams based on date, you can simply create a measure:

Accumulated Stock =
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = MAX ( 'Table'[ID] )
            && 'Table'[Index] <= MAX ( 'Table'[Index] )
    ),
    [Stock]
)

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@azaterol 

how do you get the initial stock? where does the 75 come from?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.