Hi Sam,

For the Metric Table, I used these formulas:

```
Metric Selected Sales = SELECTEDVALUE( 'Ranking Analysis Metric'[Metric Category], "Sales")
Metric Selected Profit = SELECTEDVALUE( 'Ranking Analysis Metric'[Metric Category], "Profit")
Metric Selected Margin = SELECTEDVALUE( 'Ranking Analysis Metric'[Metric Category], "Margin")
```

For the Top selection, this one:

```
`Top Ranking Select = IF(HASONEVALUE( 'Top Ranking Table'[Ranking Selection] ), VALUES( 'Top Ranking Table'[Rank Number] ), 1000000 )`
```

And for the combining selection this other one:

```
Top Selected Metric =
SWITCH( TRUE(),
[Metric Selected Sales] = "Sales", [Top Sales Customer],
'Ranking Analysis Metric'[Metric Selected Profit] = "Profit", [Top Profit Customer],
'Ranking Analysis Metric'[Metric Selected Margin] = "Margin", FORMAT( [Top Margin Customer], "0.00%"),
[Total Net Sales] )
```

My Top Margin Customer formula is the following:

```
Top Margin Customer =
VAR
RankingDimension = VALUES( 'CUSTOMER MASTER'[Customer Name] )
VAR
RankingSelection = 'Top Ranking Table'[Top Ranking Select]
RETURN
CALCULATE( [Total % Marging],
FILTER( RankingDimension,
RANKX(ALL( 'CUSTOMER MASTER'[Customer Name] ), [Total % Marging] , , DESC ) <= RankingSelection))
```

And finally, the *Total % Margin* and **Total Profit** formulas that were made as follows, because, the COGS for the current working month are not available until around the 5th day of the next month. This is a data limitation due to an internal accounting process in the company. So for instance, this means that for the month of November sales show 0 COGS until around December 5th. This causes the problem that in the BI COGS calculations and if you select 2018 you are calculating the margin with 100% for all November sales. The same would apply to the profit calculation. So the intention of these measures is to filter out dates later than the end of the previous month.

Total % Marging =

```
VAR LastMontCogs = EOMONTH( TODAY() , -1)
VAR MarginReturn = CALCULATE( DIVIDE( [Total Profit], [Total Net Sales], 0),
FILTER( 'SALES DATA', 'SALES DATA'[SALES DATE] <= LastMontCogs ))
RETURN
MarginReturn
Total Profit =
VAR ProfitLastMonth = EOMONTH(today(),-1)
VAR ProfitReturn = CALCULATE ([Total Net Sales] - [Total Cost],
FILTER ('SALES DATA','SALES DATA'[SALES DATE] <= ProfitLastMonth))
RETURN ProfitReturn
```

My goal is having the option to dynamically interact between sales/profit/margin in the same chart when I select my Top 10/25/50 customers. The filters are working perfectly fine when I select sales or margin within my Top 10, 25 or 50. The issue is only when I select the profit option if I use the FORMAT function to edit the values for being shown as % istead of decimals.

Please, let me know if you need further info …

Thanks!

Lucia