Forum Discussion

LD's avatar
LD
Frequent Visitor
4 years ago
Solved

Issue on Cumulative Sum

Dear All,

please, I have the following Dataset and I would like to measure the cumulative sum by month of [YTD_in/out]_

 

 

I try the following structure:

Var LastM = SELECTEDVALUE('Y Projection'[Month])

Var Dep = SELECTEDVALUE('Y Projection'[Department])
Return
CALCULATE(
SUM('Y Projection'[YTD_IN/OUT]),
'Y Projection'[Month]<=LastM && 'Y Projection'[Department]=Dep

 

but the Column [Colonna] didn't show any results, but any error too.

 

Please, How I can Solve?

  • LD 

    Please use

    =
    VAR LastM = 'Y Projection'[Month]
    VAR CurrentDepTable =
        CALCULATETABLE (
            'Y Projection',
            ALLEXCEPT ( 'Y Projection', 'Y Projection'[Department] )
        )
    RETURN
        SUMX (
            FILTER ( CurrentDepTable, 'Y Projection'[Month] <= LastM ),
            'Y Projection'[YTD_IN/OUT]
        )

2 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    LD 

    Please use

    =
    VAR LastM = 'Y Projection'[Month]
    VAR CurrentDepTable =
        CALCULATETABLE (
            'Y Projection',
            ALLEXCEPT ( 'Y Projection', 'Y Projection'[Department] )
        )
    RETURN
        SUMX (
            FILTER ( CurrentDepTable, 'Y Projection'[Month] <= LastM ),
            'Y Projection'[YTD_IN/OUT]
        )
    • LD's avatar
      LD
      Frequent Visitor

      Thank You Tamerj1,

      It's fine and the value are exact!!!!