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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
CuriousFlee
Frequent Visitor

Two Aggregations: Cumulative Sum of Averages Per Category Per Date

Good morning,

 

Have the following underlying data:

sedolreturnsregionsector1date
20263611.5North AmericaFinancials01/06/2023
20024791.2North AmericaIT01/06/2023
28318111.1EuropeIT01/06/2023
2002305-2EuropeFinancials01/06/2023
B92SR70-3APACMaterials01/06/2023
2026361-1North AmericaFinancials02/06/2023
2002479-2North AmericaIT02/06/2023
28318113EuropeIT02/06/2023
20023052EuropeFinancials02/06/2023
B92SR701APACMaterials02/06/2023
20263610North AmericaFinancials03/06/2023
20024790.5North AmericaIT03/06/2023
28318110.1EuropeIT03/06/2023
2002305-5EuropeFinancials03/06/2023
B92SR702APACMaterials03/06/2023

 

Requirement:

  • aggregate it in the following manner: first get the average return for a day for region and then add cumulative sum of it.
  • aggregation should be reactive and respond to external explicit filters (slicers etc)

Sample of output:

regiondateaverage_rets_per_daycum_rets
APAC01/06/2023-3.00-3.00
APAC02/06/20231.00-2.00
APAC03/06/20232.000.00
Europe01/06/2023-0.45-0.45
Europe02/06/20232.502.05
Europe03/06/2023-2.45-0.40
North America01/06/20231.351.35
North America02/06/2023-1.50-0.15
North America03/06/20230.250.10

 

Can achieve individual tasks (eg running sum, calc averages) but struggling to get everythign together in responsive output.

Help is very much appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @CuriousFlee ,

I have created a simple sample, please refer to see if it helps you.

Create 2 measures.

Measure = 
CALCULATE(AVERAGE('Table'[returns]),FILTER(ALL('Table'),'Table'[region]=SELECTEDVALUE('Table'[region])&&'Table'[date]=SELECTEDVALUE('Table'[date])))
Measure 2 = 
var tmp=WINDOW(1,abs,0,REL,ALLSELECTED('Table'[date],'Table'[region]),,,PARTITIONBY('Table'[region]))
return
SUMX(tmp,[Measure])

vrongtiepmsft_0-1716437229016.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

2 REPLIES 2
CuriousFlee
Frequent Visitor

v-rongtiep-msft, this is absolutely brilliant. Had a feeling window function must be involved, but you've just nailed. 

Great suggestion, thanks!

Anonymous
Not applicable

Hi @CuriousFlee ,

I have created a simple sample, please refer to see if it helps you.

Create 2 measures.

Measure = 
CALCULATE(AVERAGE('Table'[returns]),FILTER(ALL('Table'),'Table'[region]=SELECTEDVALUE('Table'[region])&&'Table'[date]=SELECTEDVALUE('Table'[date])))
Measure 2 = 
var tmp=WINDOW(1,abs,0,REL,ALLSELECTED('Table'[date],'Table'[region]),,,PARTITIONBY('Table'[region]))
return
SUMX(tmp,[Measure])

vrongtiepmsft_0-1716437229016.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors