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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Getting the average of data in a table, filtered 15 records

Hi, I have a table that's currently filtering the top 15 topics out of 470 total.

The table correctly shows the average of each field, but I can't seem to recreate as a measure outside of the table, that does the same thing. I can create averages for grand totals, but unable to recreate the averages in the table.

So far this is how far I got for one of the fields

AVERAGEX(
    TOPN(15, 'Topics'),
    SUM('Topics'[RowCount])
    )
which I hoped would give me the Sum based off of the filter (sum of top 15), and then divide 15/Sum.
but it keeps giving me the grand total of the entire field, ignores 
the TopN 15 filter. 

How can I create a measure that shows each of the bolded averages below, based off the # of records being filtered rather than the total table?

MRUry7_2-1692986615590.png

 

Any help is appreciated, of course!

Steve

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.
Measure:

Rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[RowCount])),,DESC)

vzhangti_0-1693486030293.png

Average rowcount = CALCULATE(SUM('Table'[RowCount]),FILTER(ALL('Table'),[Rank]<=15))/15
Average Look&Feel = CALCULATE(SUM('Table'[Look & Feel]),FILTER(ALL('Table'),[Rank]<=15))/15

vzhangti_1-1693486095396.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.
Measure:

Rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[RowCount])),,DESC)

vzhangti_0-1693486030293.png

Average rowcount = CALCULATE(SUM('Table'[RowCount]),FILTER(ALL('Table'),[Rank]<=15))/15
Average Look&Feel = CALCULATE(SUM('Table'[Look & Feel]),FILTER(ALL('Table'),[Rank]<=15))/15

vzhangti_1-1693486095396.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Thanks very much for this, it was a big help and it helped me resolve my challenge.  Thanks!

Ashish_Mathur
Super User
Super User

Hi,

Does this get the right answer?

Total = sum('Topics'[RowCount])

Average of Top 15 = AVERAGEX(TOPN(15'Topics'),[Total])

If not, then share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@Anonymous what do you define top 15? Top based on what? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

foodd
Super User
Super User

Please create a pbix file that contains some sample data but still reflects your data model (tables, relationships, calculated columns, and measures), upload the pbix to Onedrive or Dropbox, and share the link. Please use Excel to create the sample data instead of the manual input method share the xlsx as well.

 

Describe the expected results based on the sample you provide.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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