Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everbody !
I have been struggling for several hours with a measure to calculate the average selling price of the Top 10 products sold.
The difficulty: my Top 10 products must change according to the countries selected in the report.
So I have a Product table with a "Selling Price" column.
Initially I had created a calculated column in my Product table to identify the Top Products. The problem is that the ranking does not update dynamically when I select a country in my report.
So I went on a measure:
CALCULATE (
RANKX (ALL ('Product'); [Sales Amount];; DESC; DENSE);
KEEPFILTERS (Country)
)
This works well, the ranking changes according to the selected countries.
However, I don't know how I can use the result of this measure in a formula to calculate the average.
I tested this but it doesn't work 😞
CALCULATE (
AVERAGE ('Product' [SellingPrice]);
ProductRanking> = 10
)
Could you please help ? 🙂
Thanks !!
Pauline
@DIACHROMA , see if one the 4 can help you
Top 10 Rank = CALCULATE([Sales Amount],TOPN(10,allselected(Product[ProductKey]),[Sales Amount],DESC),VALUES(Product[ProductKey]))
Top 10 Rank = CALCULATE([Sales Amount],TOPN(10,allselected(Product),[Sales Amount],DESC))
Top 10 Rank = CALCULATE([Sales Amount],TOPN(10,all(Product[ProductKey]),[Sales Amount],DESC),VALUES(Product[ProductKey]))
Top 10 Rank = CALCULATE([Sales Amount],TOPN(10,all(Product),[Sales Amount],DESC))
Refer video: https://youtu.be/QIVEFp-QiOk
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...
@DIACHROMA
You create the Average Selling measure as follows:
Avg Selling Price =
CALCULATE(
AVERAGE(Products[Selling Price]),
FILTER(
ALLSELECTED(Products[Product]),
[Rank] >= 10
)
)
________________________
If my answer was helpful, please click Accept it as the solution to help other members find it useful
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Modify your Rank formula as :
Rank =
CALCULATE (
RANKX (ALL ('Product'[Product]); [Sales Amount];; DESC; DENSE);
)
If this doesn't work then you can share your pbix file with sample data.
You can save the file in OneDrive or any other platform and share the link
________________________
If my answer was helpful, please click Accept it as the solution to help other members find it useful
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi Fowmy,
Thank you very much for your answer !
However it doesn't work in my report... 😞
When I insert the formula into my report it loads for long minutes. Same when I post the report on the Service.
Pauline
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 14 | |
| 5 | |
| 5 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 10 | |
| 10 | |
| 6 | |
| 6 |