Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX Running Total based on Index

Hello, I’m new to DAX and I’m trying to get a Running Total (Supply and Demand) based on the column SKU Index: What I’m trying to do is to replicate the next formula: =IF(N2=1, J2, I1+J2-K2) The ...
  • ChenwuZhu_Gmail's avatar
    ChenwuZhu_Gmail
    4 years ago

    Hi Anonymous ,

     

    Did you solve your problem, if yes, please mark it as a solution, if not, please try these codes below to do that.

     

    My table looks like:

     

    New column to calculate:

    Column =
    SUMX (
        FILTER (
            'Table',
            [SKU] = EARLIER ( 'Table'[SKU] )
                && [SKU Index] <= EARLIER ( 'Table'[SKU Index] )
        ),
        [+] - [-]
    )

     

    Result:

     

    Measure:

    Measure =
    SUMX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [SKU] = SELECTEDVALUE ( 'Table'[SKU] )
                && [SKU Index] <= SELECTEDVALUE ( 'Table'[SKU Index] )
        ),
        [+] - [-]
    )

     

    Result:

     

    Best regards.

     

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