The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
User | Count |
---|---|
20 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
9 | |
9 |