Forum Discussion

Jazz_MT's avatar
Jazz_MT
Frequent Visitor
7 years ago
Solved

Cumulative Sum based on Period End

Hi All,

 

I am trying to calculate the cumulative sum of an amount based on some conditional logic. 

 

What I am trying to do is calculate the WIP_Taget_AMT by Per_End_Date where the WIP has not been billed therefore where WIP_CLEAR_DATE is either NULL or Greater than the Per_End_Date. 

 

I am doing the following: 

 

Running Total MEASURE =
CALCULATE (
SUM ( Wip_Detail[WIP_Target_AMT] ),
FILTER (
ALL(Wip_Detail),
Wip_Detail[Per_End_Date] <= MAX(Wip_Detail[Per_End_Date]) &&
(Wip_Detail[WIP_CLEAR_DATE] >= MAX(Wip_Detail[Per_End_Date])
)
))
 
However its not working... Can anybody help out ? 
  • Hi Jazz_MT ,

     

    Is the excepted result you need?

     

    Running Total MEASURE = 
    CALCULATE (
    SUM ( Wip_Detail[WIP_Target_AMT] ),
    FILTER (
    ALL(Wip_Detail),
    Wip_Detail[Per_End_Date] <= MAX(Wip_Detail[Per_End_Date]) &&
    (Wip_Detail[WIP_CLEAR_DATE] >= MAX(Wip_Detail[Per_End_Date])
    )
    ),VALUES(Wip_Detail[Per_End_Date]))

     

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Can you post sample data of your WIP_Detail table?

     

     

    • Jazz_MT's avatar
      Jazz_MT
      Frequent Visitor

      Hi All,

       

      Please find the table below:

       

      What I need to do is get the Running total of WIP_Target_AMT grouped by Per_End_Date where the WIP_CLEAR_DATE is greater than Per_End_Date or WIP_Clear_Date is NULL.

       

      Thanks

       

      ------ 

       

      JobEntityWIP_IDPostDatePer_End_DateWIP_Target_AMTWIP_CLEAR_DATEJobChargeCdisBilled
      1407092120/06/201930/06/2019560NULLEBNULL
      1407073520/06/201930/06/201914530/06/2019EBY
      1407078620/06/201930/06/2019110NULLEBNULL
      1407082721/06/201930/06/2019187.530/06/2019EBY
      1406945418/06/201930/06/2019362.530/06/2019EBY
      1407061719/06/201930/06/201912530/06/2019EBY
      1407005618/06/201930/06/201917530/06/2019EBY
      1407051018/06/201930/06/2019142.5NULLEBNULL
      1407007518/06/201930/06/20194930/06/2019EBY
      1407083318/06/201930/06/2019125NULLEBNULL
      1406968917/06/201930/06/2019237.5NULLEBNULL
      1407099818/06/201930/06/2019-51NULLEBNULL
      1407032619/06/201930/06/20191430/06/2019EBY
      1407036719/06/201930/06/20192530/06/2019EBY
      1407084720/06/201930/06/2019125NULLEBNULL
      1407099918/06/201930/06/201951NULLEBNULL
      1407050318/06/201930/06/2019560NULLEBNULL
      1406945617/06/201930/06/201925.530/06/2019EBY
      1407079318/06/201930/06/2019110NULLEBNULL
      1407061319/06/201930/06/201937.530/06/2019EBY
      1407083818/06/201930/06/201962.5NULLEBNULL
      1407032518/06/201930/06/201914030/06/2019EBY
      1405235910/06/201915/06/201958NULLEBNULL
      1405215504/06/201915/06/2019100NULLEBNULL
      1405127212/06/201915/06/20193330/06/2019EBY
      1405148905/06/201915/06/201912.530/06/2019EBY
      1405149110/06/201915/06/201937.530/06/2019EBY
      1405113705/06/201915/06/20191730/06/2019EBY
      1405149313/06/201915/06/201937.530/06/2019EBY
      1405149212/06/201915/06/201962.530/06/2019EBY
      1405149006/06/201915/06/201912.530/06/2019EBY
      1405216613/06/201915/06/201962.5NULLEBNULL
      1405200603/06/201915/06/201912.5NULLEBNULL
      1405213311/06/201915/06/201950NULLEBNULL
      1405192412/06/201915/06/201950NULLEBNULL
      1405214706/06/201915/06/201962.5NULLEBNULL
      1405274105/06/201915/06/201950NULLEBNULL
      1405228304/06/201915/06/2019340NULLEBNULL
      1405232614/06/201915/06/201972.5NULLEBNULL
      1404869104/06/201915/06/201912.5NULLEBNULL
  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Jazz_MT ,

     

    How about this one?

     

    Running Total MEASURE =
    CALCULATE (
    SUM ( Wip_Detail[WIP_Target_AMT] ),
    FILTER (
    ALL(Wip_Detail),
    Wip_Detail[Per_End_Date] <= MAX(Wip_Detail[Per_End_Date]) &&
    (Wip_Detail[WIP_CLEAR_DATE] <= MAX(Wip_Detail[Per_End_Date])
    )
    ))
    • Jazz_MT's avatar
      Jazz_MT
      Frequent Visitor

      It is on the right track but not fully there :( Posted below re a sample of the data. 

      Thanks for the help :) 

      • v-frfei-msft's avatar
        v-frfei-msft
        Community Support

        Hi Jazz_MT ,

         

        Is the excepted result you need?

         

        Running Total MEASURE = 
        CALCULATE (
        SUM ( Wip_Detail[WIP_Target_AMT] ),
        FILTER (
        ALL(Wip_Detail),
        Wip_Detail[Per_End_Date] <= MAX(Wip_Detail[Per_End_Date]) &&
        (Wip_Detail[WIP_CLEAR_DATE] >= MAX(Wip_Detail[Per_End_Date])
        )
        ),VALUES(Wip_Detail[Per_End_Date]))