Doubt with webmap styles 2 string variables

631
2
Jump to solution
02-25-2021 06:55 PM
Labels (3)
RodrigoLama
New Contributor III

Hello community,

I have a webmap with a layer and I need to occupy 2 fields to create the style I need, for example:

Type_field: values (type1, type2, type3)
Active_field: values (YES, NO)

I have the option to add a second field, but the second field can only be of the numeric type, it cannot be of string.

From the beginning I defined it that way.
Is there a way to change this?
or maybe it is possible to create an expression that returns a value?

 

Try creating an expression like this: Concatenate (DomainName ($ feature, "PLAN_TYPE"), '/', DomainName ($ feature, "ACTIVE"))

but it returns a message saying, "Warning
The expression must return a numeric value "

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi @RodrigoLama ,

It would be best to change the structure of your data since it does not align with what you want to obtain. You can however keep a numeric field and create a domain for it to have an understandable description of the composed value. If you want to symbolize the two fields you don't have to create a new field, you can use Arcade and concatenate the values.

If however, you want to create a unique numeric value, it might be an idea to get a structured result. Have a look at the expression below:

var active = DomainName($feature, "ACTIVE");
var plan = DomainName($feature, "PLAN_TYPE");

var dct_active = {"YES": 1, "NO": 2};
var dct_plan = {"type1": 1, "type2": 2, "type3": 3}; 

var result = 0;
if (HasKey(dct_active, active)) {
    result = dct_active[active] * 10;
} else {
    result = -1 * 10;
}

if (HasKey(dct_plan, plan)) {
    result += dct_plan[plan];
} else {
    result += -1;
}

return result;

 

A value of 13 would represent: ACTIVE Yes and PLAN_TYPE type3...

View solution in original post

2 Replies
XanderBakker
Esri Esteemed Contributor

Hi @RodrigoLama ,

It would be best to change the structure of your data since it does not align with what you want to obtain. You can however keep a numeric field and create a domain for it to have an understandable description of the composed value. If you want to symbolize the two fields you don't have to create a new field, you can use Arcade and concatenate the values.

If however, you want to create a unique numeric value, it might be an idea to get a structured result. Have a look at the expression below:

var active = DomainName($feature, "ACTIVE");
var plan = DomainName($feature, "PLAN_TYPE");

var dct_active = {"YES": 1, "NO": 2};
var dct_plan = {"type1": 1, "type2": 2, "type3": 3}; 

var result = 0;
if (HasKey(dct_active, active)) {
    result = dct_active[active] * 10;
} else {
    result = -1 * 10;
}

if (HasKey(dct_plan, plan)) {
    result += dct_plan[plan];
} else {
    result += -1;
}

return result;

 

A value of 13 would represent: ACTIVE Yes and PLAN_TYPE type3...

RodrigoLama
New Contributor III

Muchas gracias. =) solucionado.

0 Kudos