Arcade FeatureSetByName Not Returning What I Expected

804
4
Jump to solution
12-25-2022 11:14 AM
GregReinecke
New Contributor III

Hello,

I am struggling to return the attribute I want not because of Arcade but more from my logic in Arcade.

The pic below shows the same statement and the "return  aa" which returns [R] and is correct but then the "return results" returns "000000" and I thought it would return FF0000 which is what I'd like. Any guidance would be huge.

Thank you so much.

GR

Tags (3)
0 Kudos
2 Solutions

Accepted Solutions
RhettZufelt
MVP Frequent Contributor

FeatureSerByName is grabbing a feature set, and you are testing values based on a feature.  So, need to grab the feature (or features) that you are interested in first.

The post here gives a good, simple example of how to intersect and grab the result: FeatureSetBy......

Once you get it returning the result you are after ( [R], [D], [I], etc.), then you can build your "if" statements with a return for each comparisong.

R_

Also, link to entering code on forum for future reference.

 

View solution in original post

GregReinecke
New Contributor III

Rhett,

You got me thinking logically. I created the expression 

var aa = Intersects(FeatureSetByName($map, "StatesWithSenators",['Fname1','LName1', 'Balloted1']),Centroid($feature))
for (var f in aa)

if(text(f.Balloted1) == "[R]") {
  return "FF0000"
}
if(text(f.Balloted1) == "[D]") {
  return "0000FF"
}
if(text(f.Balloted1) == "[I]") {
  return "BEBEBE"
}

 and then added to the text source for my pop up

<span style="font-size:large;">Senator(s): <font color="{expression/expr8}">{expression/expr10}</font>

and it worked out perfectly. Thank you so much.

GR

 

 

View solution in original post

0 Kudos
4 Replies
RhettZufelt
MVP Frequent Contributor

Without seeing at least some code, hard to guess what you are trying to achieve, but looks like a Text() formatting useage.

Perhaps something like:

Text($feature.COLUMNAME, 'FF0000')

R_

GregReinecke
New Contributor III

Thank you Rhett. The expression below (which 've tried many ways now) ignores the evaluation and just returns ["000000"] .

 
IF (Intersects(FeatureSetByName($map, "StatesWithSenators",['Balloted1']),Centroid($feature)) == '[R]') {"FF0000"}
  else if (Intersects(FeatureSetByName($map, "StatesWithSenators",['Balloted1']),Centroid($feature)) == '[D]') {"0000FF"}
  else if (Intersects(FeatureSetByName($map, "StatesWithSenators",['Balloted1']),Centroid($feature)) == '[I]') {"BEBEBE"}
  else {"000000"}
 
I know how the this finds the [R]. [D] or [I] from the FeatureSetByName layer but no matter what I have done, it doesn't assign the corresponding color hex code which I would than use when I put the expression in some html. I appreciate your help.
Thanks,
GR
0 Kudos
RhettZufelt
MVP Frequent Contributor

FeatureSerByName is grabbing a feature set, and you are testing values based on a feature.  So, need to grab the feature (or features) that you are interested in first.

The post here gives a good, simple example of how to intersect and grab the result: FeatureSetBy......

Once you get it returning the result you are after ( [R], [D], [I], etc.), then you can build your "if" statements with a return for each comparisong.

R_

Also, link to entering code on forum for future reference.

 

GregReinecke
New Contributor III

Rhett,

You got me thinking logically. I created the expression 

var aa = Intersects(FeatureSetByName($map, "StatesWithSenators",['Fname1','LName1', 'Balloted1']),Centroid($feature))
for (var f in aa)

if(text(f.Balloted1) == "[R]") {
  return "FF0000"
}
if(text(f.Balloted1) == "[D]") {
  return "0000FF"
}
if(text(f.Balloted1) == "[I]") {
  return "BEBEBE"
}

 and then added to the text source for my pop up

<span style="font-size:large;">Senator(s): <font color="{expression/expr8}">{expression/expr10}</font>

and it worked out perfectly. Thank you so much.

GR

 

 

0 Kudos