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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |