Solved

# Use maximum values in new metric

• 2 replies
• 46 views

+1
• New Pigmenteer

Hello Community!

I created a metric where I can see the revenue of a product split by different countries per month. I can then use the aggregator “MAX” to give me the maximum obtained revenue - e.g. in which country the revenue was the highest that month. I would like to use this value (thus the name of this country) in a separate table where I have already other information on this product. What I would like to add in this table is thus “Product X - Top performing country”. Would this be possible?

Thank you very much in advance!

icon

Best answer by Benoit 27 April 2023, 15:39

View original

### 2 replies

Userlevel 5
+7

Hi Olivia,

Hope you’re well, thank you for raising this question on the Community.

With modeling there are multiple ways to build things, I hope I’ll be able to explain my logic clearly but there might be other ways.

To return the Top Country based on the Revenue per Month, I’d suggest to use an IF condition that will compare the max revenue by Product and Month to the max revenue by Product, Month and Country, if there is a match, then return the Country.

I’ve built an example:

1. ### Finally, here is the comparison + match made to return only the Top Country.

Here is the formula.

`if( DataLoad.amount [by max: DataLoad.month, DataLoad.Product]  = DataLoad.amount [by max: DataLoad.Country, DataLoad.month, DataLoad.Product] , Country) [remove firstnonblank: Country]`

My metric is dimensioned by Month and Product, but that is up to you to use these dimensions, you can do it regardless of them just by removing the useless modifiers with in the [by max: … ].

Hope it helps.

Best,
Benoit

Additional note: If two countries are equals, it would only return one result, the firstnonblank item in your Country list. So, for example if Brazil and Japan are even, Brazil would be displayed, assuming your Country dimension is sorted by alphabetical order.

+1

Hello Benoit,

Thank you very much for your answer. This was exactly what I was looking for.

Kind regards,

Olivia