Use maximum values in new metric

  • 26 April 2023
  • 2 replies

Badge +1

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! 


Best answer by Benoit 27 April 2023, 15:39

View original

2 replies

Userlevel 6
Badge +12

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. Here is my data load.


  1. Here is the metric that returns the Max revenue by Product, Month and Country. Hope it looks like what you have.


  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.



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.

Badge +1

Hello Benoit,

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

Kind regards,