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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to make average variance with week number

Here is the question:

I'd like to show every week average as below:

Week01 2

Week02 2.5

Week03 3

Week04 6

I want to show:  Week01 =2; Week02 =average(week01,week02)= 2.25; Week03= average(week01, week02,week03) = 2.5;  Week04= average (week01, week02, week03, week04) = 3.375.

How to make this happen. thanks a lot.

3 ACCEPTED SOLUTIONS
d_gosbell
Super User
Super User

You could do this with a measure like the following

Running Avg = AVERAGEX( Filter(all('Table'),'Table'[Week] <= max('Table'[Week])), 'Table'[Amount])

2020-01 running avg.png 

View solution in original post

If you want to do a running total within the categories like that I think we'd need to retain the category filters which we could do with an expression like the following:

Running Avg = 
var catTable = VALUES('Table'[Category])
var dateTable =  Filter(ALL('table'),'Table'[Week] <= max('Table'[Week]) && 'Table'[Category] IN catTable)
return AVERAGEX(  dateTable,  'Table'[Amount])

 

View solution in original post

Anonymous
Not applicable

it really does work. Thank you for your professional answer!

 

I've tried many times base on your previous answer, found that below formula also can make this happen:

 

Measure = calculate(average('Table'[Amount]),filter(ALLSELECTED('Table'),'Table'[Category]=max('Table'[Category])),FILTER(ALLSELECTED('Table'),'Table'[Week]<=max('Table'[Week])))

View solution in original post

9 REPLIES 9
d_gosbell
Super User
Super User

You could do this with a measure like the following

Running Avg = AVERAGEX( Filter(all('Table'),'Table'[Week] <= max('Table'[Week])), 'Table'[Amount])

2020-01 running avg.png 

Anonymous
Not applicable

There is one more question, I forgot to add catogory in previous question, if still need consider catogory, then how to filter? thanks.

I tried, below formula will make all catogory has the same average. 

Running Avg = AVERAGEX( Filter(all('Table'),'Table'[Week] <= max('Table'[Week])), 'Table'[Amount])

 

 Week    Amount   Catagory

   01        2.00           A

   02        2.50           A

   03        3.00           B

   04        6.00           B

If category is a column in 'Table' then using ALLEXCEPT instead of ALL as in the following might work

Running Avg = AVERAGEX( Filter(allexcept('Table', 'Table'[Category]),'Table'[Week] <= max('Table'[Week])), 'Table'[Amount])

  

Anonymous
Not applicable

 

Is my powerBI wrong?  I found that "allexcept" measure the same with "all" measure.

 

all.jpg

 

all exept.jpg


allexcept.jpg

You only have one category per week in that small sample set so you won't see any difference in those calcs. What result are you expecting to see?

Anonymous
Not applicable

I expect to get as below:  

Average should only be cal. in the same catogory. No calculation among different groups (catogory). PowerBI can realize this?  thanks.

 

WeekAmountCatogory ave.
12A 2
22.5A 2.25
33B 3
46B 4.5

If you want to do a running total within the categories like that I think we'd need to retain the category filters which we could do with an expression like the following:

Running Avg = 
var catTable = VALUES('Table'[Category])
var dateTable =  Filter(ALL('table'),'Table'[Week] <= max('Table'[Week]) && 'Table'[Category] IN catTable)
return AVERAGEX(  dateTable,  'Table'[Amount])

 

Anonymous
Not applicable

it really does work. Thank you for your professional answer!

 

I've tried many times base on your previous answer, found that below formula also can make this happen:

 

Measure = calculate(average('Table'[Amount]),filter(ALLSELECTED('Table'),'Table'[Category]=max('Table'[Category])),FILTER(ALLSELECTED('Table'),'Table'[Week]<=max('Table'[Week])))

Anonymous
Not applicable

Thank you! d_gosbell!   superman you are. 🙂

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors