Forum Discussion

azaterol's avatar
azaterol
Icon for Helper V rankHelper V
4 years ago
Solved

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 

 

  • 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.

2 Replies

  • 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.