Solved

Metric with BY ALL condition is not working properly

  • 25 April 2024
  • 2 replies
  • 17 views

Hi,

I created a metric as following:

SELECT SUM(Contacts)/ (SELECT SUM(Contacts) BY ALL Country)

I have data like following

Country Contacts
Brazil 20
NULL 30
  30
Argentina 20

 

and other countries

I then select a filter to show Top 10 and in another filter i de-select (empty value) as i don’t want to show them in the Top 10 report but instead of giving % for Brazil as 20% (20/100), it would give 50% (20/40)

icon

Best answer by Francisco Antunes 25 April 2024, 16:18

View original

2 replies

Hello there!

Thanks for the explanation, I was able to re-create this scenario on my end and have a solution to propose.

In this case, the problem is that the filter you are using to select the countries also interferes with the calculations - the metric calculates the Total customers based on what’s currently on the visualization (so if you only select Brazil and Argentina, it will consider the total Sum of Contacts to be 40, not 100).

The solution is to use the WITHOUT PF keywords to make it so the filter selection doesn’t interfere with the calculations. This way, even after removing countries from the visualization, the ratio will be calculated against the total number of Countries. It still allows you to use a TOP filter, as well, from what I tested.

Let me know if that works out!

 

Best regards,

Francisco Antunes - GoodData Support

Hello there!

Thanks for the explanation, I was able to re-create this scenario on my end and have a solution to propose.

In this case, the problem is that the filter you are using to select the countries also interferes with the calculations - the metric calculates the Total customers based on what’s currently on the visualization (so if you only select Brazil and Argentina, it will consider the total Sum of Contacts to be 40, not 100).

The solution is to use the WITHOUT PF keywords to make it so the filter selection doesn’t interfere with the calculations. This way, even after removing countries from the visualization, the ratio will be calculated against the total number of Countries. It still allows you to use a TOP filter, as well, from what I tested.

Let me know if that works out!

 

Best regards,

Francisco Antunes - GoodData Support

Awesome it worked

Reply