Skip to main content
Solved

Evaluate Attribute Syntax

  • June 6, 2019
  • 7 replies
  • 66 views

deanhowell
Influencer
Forum|alt.badge.img+24

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)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

takashi
Celebrity
  • 7843 replies
  • 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+7
  • Contributor
  • 48 replies
  • 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+24
  • Author
  • Influencer
  • 315 replies
  • 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)

Thanks @takashi you are a champion :)


deanhowell
Influencer
Forum|alt.badge.img+24
  • Author
  • Influencer
  • 315 replies
  • 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.

Thanks @geolassi very much appreciated.


deanhowell
Influencer
Forum|alt.badge.img+24
  • Author
  • Influencer
  • 315 replies
  • 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+44
  • Influencer
  • 3427 replies
  • 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?

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+24
  • Author
  • Influencer
  • 315 replies
  • June 11, 2019

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.