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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors