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
um_mir
Frequent Visitor

Cumulative Sum with two filters

Hi Experts,

 

Can someone please help me with below issue. I have data like this:

 

TableA

SequenceNumberYear
1302016
1312016
1322017
1332017
1342018
1352018
1362019

 

Measure [NetGrowth] works good.

 

My [NetGrowth] cumulative measure is

NetGrowthCumulative = 
VAR MyYearMin = MINX(TableA,TableA[Year])
VAR MyYearMax = MAXX(TableA,TableA[Year])
RETURN 
SUMX(
    FILTER(
        ALL(TableA),TableA[SequenceNumber]<=MAX(TableA[SequenceNumber]) 
            && TableA[Year]>=MyYearMin && TableA[Year]<=MyYearMax
        ),
    [NetGrowth]
)

 

 
This [NetGrowthCumulative] measure works for one year window only. It resets for every year. Please see my screen shot below where from 352 to 361 is year 2018 & 362 to 363 is year 2019.Cumulative.PNG
How can i fix this? Any solutions will be much appreciated.
 
Thank you
1 ACCEPTED SOLUTION
um_mir
Frequent Visitor

Hello,

 

I got this working. Hope below solution will help someone:

 

1. Created a measure in TableA to get selected Year

SelectedYear = 
VAR t = ALLSELECTED(TableA[Year])
RETURN 
IF(MAX(TableA[Year]) in t,1,0)

2. Cumulative Measure code

 

NetGrowthCumulative = 
SUMX(
    FILTER(
        ALLEXCEPT(TableA,TableA[Year]),
        TableA[SeqNo]<=MAX(TableA[SeqNo]) && [SelectedYear]=1
        ),
[NetGrowth])

3. Make sure there is relationship between TableA & TableB.

 

 

Regards

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @um_mir,

 

What is your meausre [NetGrowth]? Could you please share your sample data and excepted result to me, if you don't have confidential data? Please upload your file to One Drive and share the link here.

 

Regards,

Frank

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

Hi @v-frfei-msft

 

Thank you for your quick response. Please see the link for the pbxi file. I have reproduced the issue. Cummulative sum works for a year and it resets again in the next year. For the attached example NetGrowthCumulative I'm exepecting below result:

 

YearSeqNoNetGrowthNetGrowthCumulative
20181100100
2018250150
2018395245
20184-50195
20185120315
2019620335
2019780415

 

Regards

um_mir
Frequent Visitor

Hello,

 

I got this working. Hope below solution will help someone:

 

1. Created a measure in TableA to get selected Year

SelectedYear = 
VAR t = ALLSELECTED(TableA[Year])
RETURN 
IF(MAX(TableA[Year]) in t,1,0)

2. Cumulative Measure code

 

NetGrowthCumulative = 
SUMX(
    FILTER(
        ALLEXCEPT(TableA,TableA[Year]),
        TableA[SeqNo]<=MAX(TableA[SeqNo]) && [SelectedYear]=1
        ),
[NetGrowth])

3. Make sure there is relationship between TableA & TableB.

 

 

Regards

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.