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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure to show the average of bottom N

How to find the sum and average of the 5 lowest numbers in a table and store it in a measure?

Also, how to find the sum and the average of the top 5 numbers in a table and store it in a measure?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous  - All 3 measures involve a 2-step process.

  1. Find the relevant rows.
  2. Perform an Aggregation

Bottom 5 Average:

 

Bottom 5 Average = 
var _bottom5 = TOPN(5, 'YourTable', [YourColumn], ASC)
return AVERAGEX(_bottom5, [YourColumn])

 

 Top 5 Average:

 

Top 5 Average = 
var _top5 = TOPN(5, 'YourTable', [YourColumn], DESC)
return AVERAGEX(_top5, [YourColumn])

 

Top 5 Sum:

 

Top 5 Average = 
var _top5 = TOPN(5, 'YourTable', [YourColumn], DESC)
return SUMX(_top5, [YourColumn])

 

View solution in original post

2 REPLIES 2
dax
Community Support
Community Support

Hi ameyabhave,

You could try to refer to above suggestions, if this is not what you want , please correct me and inform me more detailed informations(such as your sample data and your expected output), then I will hrlp you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

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

Anonymous
Not applicable

@Anonymous  - All 3 measures involve a 2-step process.

  1. Find the relevant rows.
  2. Perform an Aggregation

Bottom 5 Average:

 

Bottom 5 Average = 
var _bottom5 = TOPN(5, 'YourTable', [YourColumn], ASC)
return AVERAGEX(_bottom5, [YourColumn])

 

 Top 5 Average:

 

Top 5 Average = 
var _top5 = TOPN(5, 'YourTable', [YourColumn], DESC)
return AVERAGEX(_top5, [YourColumn])

 

Top 5 Sum:

 

Top 5 Average = 
var _top5 = TOPN(5, 'YourTable', [YourColumn], DESC)
return SUMX(_top5, [YourColumn])

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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