Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Dear People,
I hope you're doing well. I'd like to ask about DAX tips to you. I have a case to figure out Grand Average of several items within specific rank.
The following image is a list of all items that I sorted based on their Average values. As you can see, Ethiopia has the highest Average value and followed by the other countries. The grand average of all items is 81.95 Grand Average of all items
However, I'd like to find out the Grand Average value of items that are outside Top 3. I created a measure in order to make me easy to adjust N value (It could be 4, 5, 10, etc. But in this case let's assume the N has a fixed value). The DAX is shown in the image below as follows:DAX with fixed N value of 3
After applying this measure, instead of getting different value, I got the exact same Grand Average value of all items. Grand Average of items outside Top 3
I compare the Grand Average of "Outside Top N" using DAX with the Grand Average of "Outside Top N" using visual filter. You can see the images as follows:Grand Average of Outside Top N using Visual Filter
Filter out Top 3 items
As you can see the Grand Average is 81.80 by excluding Top 3 items (Ethiopia, Papua New Guinea, and United States). This is my expected result.
In short, I want to create a measure to obtain a Grand Average of items beyond top 3 that rules out top 3 items. Could you please help me to figure out the bug in my DAX? Thank you.
Regards
Solved! Go to Solution.
@Morran , Try a measure like
if(isninscope('Table'[Country]), [Avg TCP] ,
AverageX(keepfilters(topn(10, ALLselected('Table'[Country]) , [Avg TCP])), [Avg TCP])
)
you can use TOPN or window
TOPN: https://youtu.be/QIVEFp-QiOk
TOPN with Numeric Parameter -https://youtu.be/cN8AO3_vmlY?t=26448
Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
@Morran , Try a measure like
if(isninscope('Table'[Country]), [Avg TCP] ,
AverageX(keepfilters(topn(10, ALLselected('Table'[Country]) , [Avg TCP])), [Avg TCP])
)
you can use TOPN or window
TOPN: https://youtu.be/QIVEFp-QiOk
TOPN with Numeric Parameter -https://youtu.be/cN8AO3_vmlY?t=26448
Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
Hi @amitchandak , Thanks for your response. Let me try and get back to you. Thanks.
Regards
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |