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! Learn more

Reply
arp2
Helper II
Helper II

Average of top 5 values

Team, I want a measure to calculate the Average of the top 5 Values in the below table. Any suggestions plz!

Week Forecast Hours
1-Feb 45
8-Feb 48
15-Feb 45
22-Feb 20
29-Feb 25
7-Mar 45
14-Mar 49
21-Mar 25
28-Mar 28
4-Apr 27
11-Apr 26
18-Apr 24
25-Apr 21
2 ACCEPTED SOLUTIONS
zenisekd
Super User
Super User

Hi, try: 

Top5_Average = AVERAGEX( TOPN(5, ALL('YourTableName'[Forecast Hours]), 'YourTableName'[Forecast Hours], DESC), 'YourTableName'[Forecast Hours] )

Kudos and mark as solution appreciated.

View solution in original post

The problem is caused by using my measures in a calculated columns instead of using as a measure.
Use mearues instead of calculated columns and it will works fine.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

11 REPLIES 11
_AAndrade
Super User
Super User

Hi,

Use this formula:

_AAndrade_0-1708085730116.png

If you want to check that the result is correct, change AVERAGEX to SUMX and check that the numbers are correct.
On my side, my formula gives me the correct numbers. Unfortunately, zenisekd's formula is not giving the correct numbers





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade 

Can you plz help on this? I want a measure which will sum all the records per week and then take average of top 5.

Week Discipline Project Forecast Hours
45323 Disc1 Project1 45
45330 Disc1 Project1 48
45337 Disc1 Project1 45
45344 Disc1 Project1 20
45351 Disc1 Project1 25
45358 Disc1 Project1 45
45365 Disc1 Project1 49
45372 Disc1 Project1 25
45379 Disc1 Project1 28
45386 Disc1 Project1 27
45393 Disc1 Project1 26
45400 Disc1 Project1 24
45407 Disc1 Project1 21
45323 Disc1 Project2 49
45330 Disc1 Project2 37
45337 Disc1 Project2 35
45344 Disc1 Project2 54
45351 Disc1 Project2 36
45358 Disc1 Project2 42
45365 Disc1 Project2 40
45372 Disc1 Project2 35
45379 Disc1 Project2 36
45386 Disc1 Project2 35
45393 Disc1 Project2 36
45400 Disc1 Project2 37
45407 Disc1 Project2 51
45323 Disc1 Project3 51
45330 Disc1 Project3 49
45337 Disc1 Project3 52
45344 Disc1 Project3 46
45351 Disc1 Project3 56
45358 Disc1 Project3 58
45365 Disc1 Project3 64
45372 Disc1 Project3 53
45379 Disc1 Project3 64
45386 Disc1 Project3 47
45393 Disc1 Project3 48
45400 Disc1 Project3 64
45407 Disc1 Project3 53

Use this two measures:

_AAndrade_0-1708089229521.png

 

_AAndrade_1-1708089268518.png


Final result:

_AAndrade_2-1708089285562.png

 

 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade  What is "@totWeek"? I am trying the same but don't get it

@arp2 It's one variable created on the summarize function, that represents the SUM the forecast hours by week





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




@_AAndrade  Can you plz check what wrong am I doing? 

The problem is caused by using my measures in a calculated columns instead of using as a measure.
Use mearues instead of calculated columns and it will works fine.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Thanks @_AAndrade  It's working perfectly after correcting my mistake. Great help indeed!

zenisekd
Super User
Super User

Hi, try: 

Top5_Average = AVERAGEX( TOPN(5, ALL('YourTableName'[Forecast Hours]), 'YourTableName'[Forecast Hours], DESC), 'YourTableName'[Forecast Hours] )

Kudos and mark as solution appreciated.

Thanks @zenisekd this is helpful. If I have multiple records for the each week, how to calculate average of aggregated number per week?

Week Discipline ProjectForecast Hours
1-Feb Disc1 Project145
8-Feb Disc1 Project148
15-Feb Disc1 Project145
22-Feb Disc1 Project120
29-Feb Disc1 Project125
7-Mar Disc1 Project145
14-Mar Disc1 Project149
21-Mar Disc1 Project125
28-Mar Disc1 Project128
4-Apr Disc1 Project127
11-Apr Disc1 Project126
18-Apr Disc1 Project124
25-Apr Disc1 Project121
1-Feb Disc1 Project250
8-Feb Disc1 Project250
15-Feb Disc1 Project235
22-Feb Disc1 Project249
29-Feb Disc1 Project244
7-Mar Disc1 Project255
14-Mar Disc1 Project242
21-Mar Disc1 Project248
28-Mar Disc1 Project254
4-Apr Disc1 Project249
11-Apr Disc1 Project254
18-Apr Disc1 Project251
25-Apr Disc1 Project240
1-Feb Disc1 Project364
8-Feb Disc1 Project346
15-Feb Disc1 Project353
22-Feb Disc1 Project348
29-Feb Disc1 Project354
7-Mar Disc1 Project353
14-Mar Disc1 Project354
21-Mar Disc1 Project364
28-Mar Disc1 Project354
4-Apr Disc1 Project345
11-Apr Disc1 Project353
18-Apr Disc1 Project365
25-Apr Disc1 Project345

Try:
AverageForecastHoursPerWeek =
VAR WeeklySummary = SUMMARIZE ( Table1, Table1[Week], "Total Forecast Hours", SUM ( Table1[Forecast Hours] ) )
RETURN AVERAGEX ( WeeklySummary, [Total Forecast Hours] / COUNTROWS ( WeeklySummary ) )

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