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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
navafolk
Helper IV
Helper IV

Cumulative Average of another measure(s)

Hi pros,

I am facing issue that I would want to create measure of cumulative average of another measure.

The input table looks like:

DateItemAmount-baseAmount-added
01-MayLocA10011
01-MayLocB10510
01-MayLocC959
02-MayLocA10711
02-MayLocB999
02-MayLocC909
03-MayLocA10211
03-MayLocB10011
03-MayLocC979

I prepare some measures:

 

 

Total LocA = CALCULATE(sum('Table'[Amount-base])+Sum('Table'[Amount-added]),'Table'[Item]="LocA")
Total LocB = CALCULATE(sum('Table'[Amount-base])+Sum('Table'[Amount-added]),'Table'[Item]="LocB")

 

 

 and measure of gap between LocA and LocB:

 

 

Gap LocA-B = [Total LocA]-[Total LocB]

 

 

 I need a cumulative average (cumulative since beginning date in the input table to the calculating date). This is what I have tried, but it did not work.

 

 

AVG LocA-B = calculate(averagex('Table',[Gap LocA-B]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=max('Table'[Date])))

 

 

 My desired result would be:

navafolk_0-1719220154005.png

 

Please help me with this measure. Thank you, all.

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @navafolk ,

 

Try the following code:

AVG LocA-B = AVERAGEX(
			FILTER(
				ALLSELECTED('Table'[Date]),
				'Table'[Date] <= MAX('Table'[Date])
			),
			[Gap LocA-B]
		)

MFelix_0-1719234593883.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

DataInsights
Super User
Super User

@navafolk,

 

Try this measure using the WINDOW function:

 

AVG LocA-B =
VAR vTable =
    ALLSELECTED ( 'Table'[Date] )
VAR vResult =
    AVERAGEX (
        WINDOW ( 0, ABS, 0, REL, vTable, ORDERBY ( 'Table'[Date], ASC ) ),
        [Gap LocA-B]
    )
RETURN
    vResult

 

DataInsights_0-1719234778137.png

 





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
DataInsights
Super User
Super User

@navafolk,

 

Try this measure using the WINDOW function:

 

AVG LocA-B =
VAR vTable =
    ALLSELECTED ( 'Table'[Date] )
VAR vResult =
    AVERAGEX (
        WINDOW ( 0, ABS, 0, REL, vTable, ORDERBY ( 'Table'[Date], ASC ) ),
        [Gap LocA-B]
    )
RETURN
    vResult

 

DataInsights_0-1719234778137.png

 





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

Proud to be a Super User!




Great thanks, @DataInsights.

WINDOW works well and is too new to me, will research for future usage.

MFelix
Super User
Super User

Hi @navafolk ,

 

Try the following code:

AVG LocA-B = AVERAGEX(
			FILTER(
				ALLSELECTED('Table'[Date]),
				'Table'[Date] <= MAX('Table'[Date])
			),
			[Gap LocA-B]
		)

MFelix_0-1719234593883.png

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Super! Just simply what I need, I was too much thinking of CALCULATE, :D.

Thank you @MFelix 
(*) just a note for myself, I does not work with 'Date Hierarchy' in visual.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.