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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DIACHROMA
Helper II
Helper II

Average selling price of the dynamic Top 10 products

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

4 REPLIES 4
amitchandak
Super User
Super User

@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...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Fowmy
Super User
Super User

@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 🙂


Website YouTube  LinkedIn

 

 

 

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@DIACHROMA 

 

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 🙂


Website YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.