The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Top 10 Growth % =
VAR _rankingContext =
VALUES ( Companies[Company] )
RETURN
CALCULATE (
[Net Sales Growth %],
TOPN ( 10, ALL ( Companies[Company] ), [Net Sales Growth %] ),
_rankingContext,
NOT Companies[Company] IN { "Company A", "Company B" }
)
Hello Power Bi Community,
I am seeking help with my Top N function. Currently, the function displays the top 8 rather than the top 10 companies since both company A and company B are in the top 10 for net sales growth. However, I want it to display top 10 after excluding those companies from the calculations. Any idea how to approach this?
Your help is much appreciated.
Thanks,
Peter
Solved! Go to Solution.
Hi @Peter_Yaacoub ,
Please try to update the formula of the measure [] as below and check if it can return your expected result... You can find the details in the attachment.
Top 10 Growth % =
VAR _selcompany =
SELECTEDVALUE ( 'Companies'[Company] )
VAR _rank =
RANKX (
FILTER (
ALLSELECTED ( 'Companies'[Company] ),
NOT Companies[Company] IN { "Company A", "Company B" }
),
[Net Sales Growth %]
)
RETURN
IF (
NOT _selcompany
IN { "Company A", "Company B" }
&& _rank <= 10,
[Net Sales Growth %],
BLANK ()
)
If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Good morning! Would this measure help with filtering a table by the TopN brands, excluding names of specific brands? Previously, I was using a filter on the VIsual that showed the Top 3 Brands by Vol Sales, however I realized one of our own brands isn't the Top Brand in the category at a specific account and I want our brands to always be visible in the matrix
Hi @Peter_Yaacoub ,
Please try to update the formula of the measure [] as below and check if it can return your expected result... You can find the details in the attachment.
Top 10 Growth % =
VAR _selcompany =
SELECTEDVALUE ( 'Companies'[Company] )
VAR _rank =
RANKX (
FILTER (
ALLSELECTED ( 'Companies'[Company] ),
NOT Companies[Company] IN { "Company A", "Company B" }
),
[Net Sales Growth %]
)
RETURN
IF (
NOT _selcompany
IN { "Company A", "Company B" }
&& _rank <= 10,
[Net Sales Growth %],
BLANK ()
)
If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards