Forum Discussion

mhrkhader01's avatar
mhrkhader01
Icon for Helper I rankHelper I
5 years ago
Solved

I Need a Measure not a Power Query Formula - Accumulative column

Dear Team suppose we work in sales, every month there is a target, for one of the Month, if you exceed the target, then i need to save this increase in Accumulative column. lets take example **...
  • ERD's avatar
    5 years ago

    Hi mhrkhader01 ,

    You can try the next option:

    Create these measures:

    #Accum = 
    VAR currentDate = SELECTEDVALUE ( T[Date] )
    VAR sumAmt =
        CALCULATE (
            SUM ( T[Diff] ),
            FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate )
        )
    RETURN sumAmt

     

    #AccumFiltered = 
    VAR currentDate = SELECTEDVALUE ( T[Date] )
    VAR firstDatValue = MINX ( ALLSELECTED ( T ), T[Date] )
    VAR minValue = MINX ( FILTER ( T, T[Date] = firstDatValue ), T[Diff] )
    VAR sumAmt =
        CALCULATE (
            SUM ( T[Diff] ),
            FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate )
        )
    VAR minOfSum =
        MIN (
            0,
            MINX ( FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate ), [Accum] )
        )
    RETURN
        IF (
            currentDate = firstDatValue && minValue < 0,
            sumAmt - minValue,
            sumAmt - minOfSum
        )

     

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

  • ERD's avatar
    ERD
    5 years ago

    mhrkhader01 ,

    You can use MAX instead of SELECTEDVALUE .

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