Skip to main content
Solved

Evaluate Attribute Syntax


deanhowell
Influencer
Forum|alt.badge.img+23

Hello FME Gurus,

 

I have a list which contains a known sequence of values that represent different things but are linked.

I have created a list and I am then searching in the list for a specific word, in this case 'PM'

The ID for the PM is located two spots in the list before the word PM.

I am trying to extract the ID from the list dynamically but can't seem to get the syntax correct in Attribute Manager.

 

@Value(_surveytable{@Evaluate(@sub((_list_index),2))}.autocad_text_string)

 

Can anyone help is getting the index value syntax correct so I get the value that is located in the index minus 2?

Thanks

Dean

 

Best answer by takashi

I think this expression works for you if the "_list_index" attribute has a number greater than 1.

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)
View original
Did this help you find an answer to your question?

7 replies

takashi
Influencer
  • Best Answer
  • June 6, 2019

I think this expression works for you if the "_list_index" attribute has a number greater than 1.

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

geolassi
Contributor
Forum|alt.badge.img+5
  • Contributor
  • June 6, 2019

Hi! This would work:

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

I tested with sub function too, but couldn't get it working inside @Evaluate. No errors, but no result. It might be a bug related to sub, since e.g. max is working just fine inside @Evaluate, and it has a similar syntax.

EDIT: Just noticed Takashi had already posted an answer.


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • June 6, 2019
takashi wrote:

I think this expression works for you if the "_list_index" attribute has a number greater than 1.

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

Thanks @takashi you are a champion :)


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • June 6, 2019
geolassi wrote:

Hi! This would work:

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

I tested with sub function too, but couldn't get it working inside @Evaluate. No errors, but no result. It might be a bug related to sub, since e.g. max is working just fine inside @Evaluate, and it has a similar syntax.

EDIT: Just noticed Takashi had already posted an answer.

Thanks @geolassi very much appreciated.


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • June 7, 2019

Thanks all, the suggestions above worked but only gave me the first match using List Searcher.

Is there a way to loop through all values in the list?


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • June 7, 2019
deanhowell wrote:

Thanks all, the suggestions above worked but only gave me the first match using List Searcher.

Is there a way to loop through all values in the list?

It seems like you're building the list in the first place - if you just want to keep every feature that is 2 places in front of the feature with the value in PM you could use the adjacent attribute function with a conditional in an attributecreator without building a list

So for each feature, test whether the feature that is 2 after it equals PM. If it does, make a new attribute called PM holding the value in the autocad_text_string.

If there's another reason for using the list and I had to loop through it i'd probably resort to python.

Example:

two_in_front.fmwt

 


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • June 11, 2019
ebygomm wrote:

It seems like you're building the list in the first place - if you just want to keep every feature that is 2 places in front of the feature with the value in PM you could use the adjacent attribute function with a conditional in an attributecreator without building a list

So for each feature, test whether the feature that is 2 after it equals PM. If it does, make a new attribute called PM holding the value in the autocad_text_string.

If there's another reason for using the list and I had to loop through it i'd probably resort to python.

Example:

two_in_front.fmwt

 

Thanks @egomm, that worked perfectly after tweaking the index values to get the correct values.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings