# show sum in cluster label

708
3
08-10-2021 03:51 PM
MVP Regular Contributor

How do I get the sum not the average in my cluster label?

1 Solution

Accepted Solutions
MVP Regular Contributor

I found one way to do it (line 3)... but if feels like it is not the best. I feel like I should be able to get the sum directly:

``````  \$feature["cluster_avg_CUSTOMERS_AFFECTED"];
var no_feature = \$feature["cluster_count"];
var value = \$feature["cluster_avg_CUSTOMERS_AFFECTED"] * no_feature;
var num = Count(Text(Round(value)));
var label = When(
num < 4, Text(value, "#.#"),
num == 4, Text(value / Pow(10, 3), "#.0k"),
num <= 6, Text(value / Pow(10, 3), "#k"),
num == 7, Text(value / Pow(10, 6), "#.0m"),
num > 7, Text(value / Pow(10, 6), "#m"),
Text(value, "#,###")
);
return label;
``````

3 Replies
MVP Regular Contributor

I found one way to do it (line 3)... but if feels like it is not the best. I feel like I should be able to get the sum directly:

``````  \$feature["cluster_avg_CUSTOMERS_AFFECTED"];
var no_feature = \$feature["cluster_count"];
var value = \$feature["cluster_avg_CUSTOMERS_AFFECTED"] * no_feature;
var num = Count(Text(Round(value)));
var label = When(
num < 4, Text(value, "#.#"),
num == 4, Text(value / Pow(10, 3), "#.0k"),
num <= 6, Text(value / Pow(10, 3), "#k"),
num == 7, Text(value / Pow(10, 6), "#.0m"),
num > 7, Text(value / Pow(10, 6), "#m"),
Text(value, "#,###")
);
return label;
``````

Esri Regular Contributor

Yep. That is one way to work around the issue for now. The problem with this, however is the size of the cluster doesn't adjust to use the sum. It still uses the average, which can lead to some really small sized clusters with larger numbers than clusters with a larger size.

This is something we should support. Still working on some details to help it fit with the existing API smoothly. No timeline at the moment.

MVP Regular Contributor

Thanks for the feedback Kristian. Yes, the sizing issue is likely a deal breaker for me. I may not be able to use clustering at all until esri improves things.