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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
AlexH330
Frequent Visitor

Calculating with average of measure on a row level

Hi,

 

I have a measure that needs to be averaged and operated on at a row level. From this forum, it seems that the below is the correct syntax for the 'average' of a measure

 

ValueAVerage = CALCULATE([Value], ALLSELECTED('Table'[Date])

 

This works on a matrix level, however when trying a cumulative sum function for each date, it reverts back to the value for that date alone. This is because ALLSELECTED is referring only to the current date I guess? Though basic operators work (+/-). See below chart.

 

DateValueValueAverageCumulSum (what does show)Cumulsum (what should show)
19696
2261112
3761818

 

I'm using the below as a basic cumulative sum function, nothing special:

 

Cumulsum = CALCULATE([ValueAverage], FILTER(ALLSELECTED('Table'),'Table'[Date] <= MAX('Table'[Date])))

 

I've also tried the below to no avail

 

AVERAGEX(SUMMARIZE('Table',Table[Date],"avg",[Measure]),[avg])

 

I need to have the average of the entire measure, and have each row calculate by that average. How do I do this?

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AlexH330 ,

 

Please refer these measures.

Measure = CALCULATE(AVERAGE('Table'[Value]),ALL('Table'))

Measure 2 = SUMX(FILTER(ALLSELECTED('Table'),'Table'[date]<=MAX('Table'[date])),[Measure])

 13.PNG

 

Best Regards,

Jay

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @AlexH330 ,

 

Please refer these measures.

Measure = CALCULATE(AVERAGE('Table'[Value]),ALL('Table'))

Measure 2 = SUMX(FILTER(ALLSELECTED('Table'),'Table'[date]<=MAX('Table'[date])),[Measure])

 13.PNG

 

Best Regards,

Jay

amitchandak
Super User
Super User

@AlexH330 , Try like

Cumulsum = [ValueAverage]*CALCULATE(distinctcount('Table'[Date] ), FILTER(ALLSELECTED('Table'),'Table'[Date] <= MAX('Table'[Date])))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

 

 

@amitchandak clever! that almost worked. However there is 1 pressing issue:

 

1. When the series is consistent (ie has the same number for multiple days) the sum works correctly. When that value changes within the series, the sum actually subtracts, but it subtracts a random number. After that, the series sums correctly again. See below, date 4 is incorrect (sorry for the formatting, I get an HTML error on these boards)

 

Date       Value        CumulSum
1             2                2

2             2                4

3             2                6

4             3                5

5             3                8

 

Any idea what's going on here?

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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