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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Vipin_n
New Member

Top N products for top n country and GM%

Hello,

Following measures are available with me on power BI

1. Net Sales $== SUM(fact_actuals_forecast[net_sales_amount])

2. Gross Mmargin $= [NS $] - [Total operational cost]

3. Gross Margin %= DIVIDE([GM $],[NS $],0)


I have fowwing visual reports on dashboard

1. table report= this is showing top 5 countries based on Gross Margin % measure

 

I want to show top 5 produsts based on top 5 countries in a way
if no country is selected in table report, then it will show top 5 products based on Gross Margin % measure and first country in above table report.
if any country is selected then it will show the top 5 product based on Gross Margin % measure and the selected country.

 

Thanks,

Vipin

3 REPLIES 3
v-xuxinyi-msft
Community Support
Community Support

Hi @Vipin_n 

 

@ryan_mayu , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:

 

My sample:

vxuxinyimsft_0-1717390994991.png

 

@Vipin_n , The following formula is just to restore your scenario.

divide = 
VAR _sumOfProfit = SUM('Table'[Profit])
VAR _sumOfSales = SUM('Table'[Sales])
RETURN
DIVIDE(_sumOfProfit, _sumOfSales)

 

1. Create a calculated table as slicer

slicer = VALUES('Table'[Country])

 

2. Create a measure as follows

Rank = 
VAR _rankAll = RANKX(ALL('Table'), [divide], , DESC, Dense)
VAR _rank = RANKX(FILTER(ALL('Table'), [Country] IN VALUES(slicer[Country])), [divide], , DESC, Dense)
RETURN
IF(NOT(ISFILTERED(slicer[Country])), _rankAll, IF(ISFILTERED(slicer[Country]) && MAX([Country]) IN VALUES(slicer[Country]), _rank, BLANK()))

 

3. Put the Rank measure into the visual-level filters, set up as follow

vxuxinyimsft_1-1717391337241.png

 

Output:

vxuxinyimsft_2-1717391359656.png

 

vxuxinyimsft_3-1717391385821.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

I guess I'm not able to describe the problem satament correctly, let me include some more details.

Model View :

Vipin_n_0-1717399843983.png

 

Measures:

1. NS $== SUM(fact_actuals_forecast[net_sales_amount])

2. GM $= [NS $] - [Total operational cost]

3. Gross Margin %= DIVIDE([GM $],[NS $],0)

 

Visuals on dashboard:

Vipin_n_4-1717401297251.png

 

When user select any one country in visual-1 , then visual -2 shows the top 5 products by selected country and GM%. this is working properly.

 

Issue: When no country is selected in visual-1,In I want to show the top 5 products by GM% for Country Canada in visual-2 which is the first country in the visual-1.

 

Thanks,

Vipin

 

ryan_mayu
Super User
Super User

could you pls provide some sample data and expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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