Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Jazz_MT
Frequent Visitor

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 ? 
1 ACCEPTED SOLUTION

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]))

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

7 REPLIES 7
v-frfei-msft
Community Support
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])
)
))
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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

Thanks for the help 🙂 

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]))

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Can you post sample data of your WIP_Detail table?

 

 

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
Anonymous
Not applicable

RunningTotal = SUMX(
    FILTER(
        ALL(Wip_Details),
        Wip_Details[PostDate]<=MAX(Wip_Details[Per_End_Date])
        && OR( ISBLANK(Wip_Details[WIP_CLEAR_DATE]),
              Wip_Details[WIP_CLEAR_DATE]>MAX(Wip_Details[Per_End_Date])
            )
        )
        ,Wip_Details[WIP_Target_AMT]
    )

Hi,

Share the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Top Kudoed Authors