Good morning,
Is there a way to calculate the Count() using two fields instead of one? I am looking for a way find the frequency of two fields together. Something like Count(field1, field2)
This is the SQL statement:
SELECT COUNT(*) AS total_records
FROM (
SELECT DISTINCT
[field1],
[field1]
FROM MyLayer
) AS distinct_records;
Hi @SanchezNuñez,
Text widget supports Arcade. Arcade expressions can be used for calculation.
Thanks,
Ke
Good morning Could you please provide a sample of this calculation that involves two variables in Arcade for this case.
This is the sample I got from Copilot:
var ds = $dataSource; // references the feature layer
var combos = [];
for (var feature in ds) {
combos[Count(combos)] = feature.RECORD_BOOK + "-" + feature.PAGE;
}
var distinctCombos = Distinct(combos);
return Count(distinctCombos);
I do not understand how to insert this code in the text widget:
This is the default code generated in the test widget Arcade:
function getFilteredFeatureSet(ds) {
var result = ds.layer;
var queryParams = ds.queryParams;
if (!IsEmpty(queryParams.where)) {
result = Filter(result, queryParams.where);
}
if (!IsEmpty(queryParams.geometry)) {
result = Intersects(result, queryParams.geometry);
}
return result;
}
Thanks