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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Cumulative sum group by 2 factors

Hi,

This is my example table which is named 'OP 2018'.

SBUDateDaily Target_OPCumulative Daily Target_OP
A2018-09-011010
A2018-09-021020
A2018-09-031030
A2018-09-041040
A2018-09-051050
A2018-10-232020
A2018-10-242040
A2018-10-252060
A2018-10-262080
A2018-10-2720100
B2018-09-011515
B2018-09-021530
B2018-09-031545
B2018-09-041560
B2018-09-051575
B2018-10-232121
B2018-10-242142
B2018-10-252163
B2018-10-262184
B2018-10-2721105
C2018-09-011717
C2018-09-021734
C2018-09-031751
C2018-09-041768
C2018-09-051785
C2018-10-231212
C2018-10-241224
C2018-10-251236
C2018-10-261248
C2018-10-271260
D2018-09-011111
D2018-09-021122
D2018-09-031133
D2018-09-041144
D2018-09-051155
D2018-10-2388
D2018-10-24816
D2018-10-25824
D2018-10-26832
D2018-10-27840

 

I want to have a result of 'Cumulative Daily Target_OP' number so I input below,

 

Cumulative Daily Target_OP = IF(ISBLANK(if('OP 2018'[Date]<=today(),CALCULATE (
    SUM ( 'OP 2018'[Daily Target_OP] ),
    ALLEXCEPT('OP 2018','OP 2018'[SBU]),
    'OP 2018'[Date] <= EARLIER ( 'OP 2018'[Date] )
))),0,if('OP 2018'[Date]<=today(),CALCULATE (
    SUM ( 'OP 2018'[Daily Target_OP] ),
    ALLEXCEPT('OP 2018','OP 2018'[SBU]),
    'OP 2018'[Date] <= EARLIER ( 'OP 2018'[Date] )
)))

 

But it doesn't work.. Maybe I've omitted for grouping by month but I cannot make it.

Please help me to find out the correct one.

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

CummTotal = CALCULATE(SUM(Test40CummTotal[Daily Target_OP]),
FILTER(Test40CummTotal,Test40CummTotal[SBU]=EARLIER(Test40CummTotal[SBU])
&& Test40CummTotal[Date] <= EARLIER(Test40CummTotal[Date])
&& FORMAT(Test40CummTotal[Date],"YYYYMM") = FORMAT(EARLIER(Test40CummTotal[Date]),"YYYYMM")
)
)

 image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

3 REPLIES 3
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

CummTotal = CALCULATE(SUM(Test40CummTotal[Daily Target_OP]),
FILTER(Test40CummTotal,Test40CummTotal[SBU]=EARLIER(Test40CummTotal[SBU])
&& Test40CummTotal[Date] <= EARLIER(Test40CummTotal[Date])
&& FORMAT(Test40CummTotal[Date],"YYYYMM") = FORMAT(EARLIER(Test40CummTotal[Date]),"YYYYMM")
)
)

 image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar 

 

Hi tried your solution, didn't work for me.  I gave 2 regions but for 1 only it worked.

 

sbhan4_0-1597351966890.png

 

Anonymous
Not applicable

Thank you very much! It  really works 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.