Skip to main content
Solved

expression and set attribute

  • December 16, 2019
  • 9 replies
  • 57 views

Forum|alt.badge.img

Hello

 

 

I 'm tring to set any value to AttibuteManager Transformer as you can see in the attachement.

 

I have created an RandomNumberGenerator to fill a list but it doesn't work.

 

I try also a rand function. Without success.

 

Short, how to set random value in an AttibuteManager Transformer ? (the easiest way ...)

 

Subsidiary question, how to create correct expression with the "text editor_attribute value" ?

 

any help will be welcome.

thanks

 

Best answer by jerome

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

View original
Did this help you find an answer to your question?

9 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

The RandomNumberGenerator should work, as for the rand() function, you need to make sure you use the Artithmetic editor for that rather than the Text editor, which you have done now.

0684Q00000ArKVIQA3.png

(note the different icon)

The rand() function will result in a random floating point value, if you need integers you'll need to wrap it in an int() function so you'll get 

@int(@rand()*10))

Can you tell us what the output of the RandomNumberGenerator is and what you were expecting?


Forum|alt.badge.img
  • Author
  • Best Answer
  • December 16, 2019

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 


redgeographics
Celebrity
Forum|alt.badge.img+49
jerome wrote:

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

The Help of the Artithmetic editor covers those functions as well.

As for the RandomNumberGenerator, without seeing your workspace I can't really say what's going on. Could you share that by any chance?


takashi
Influencer
  • December 16, 2019
jerome wrote:

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ...  Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

I believe that the RandomNumberGenerator helps you. Try this setting.

0684Q00000ArM7wQAF.png

 

See also these links to learn more about math expressions.

This expression would work for you, FYI.

@int(@rand()*25)%25

Forum|alt.badge.img
  • Author
  • December 16, 2019
jerome wrote:

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

Sorry I forget to put my screenshot... But nothing is wrong when setting the transformer

@takashi : thanks I found an approximate formula with round.Safe_attribute1.PNG


redgeographics
Celebrity
Forum|alt.badge.img+49
jerome wrote:

Sorry I forget to put my screenshot... But nothing is wrong when setting the transformer

@takashi : thanks I found an approximate formula with round.Safe_attribute1.PNG

Note that there's nothing going into the RandomNumberGenerator. If you want to apply the random number to the 186 features shown at the top you'll need to run them through the RandomNumberGenerator. You can name the attribute to Utilisation straight away, saving you one step in the AttributeCreator.


Forum|alt.badge.img
  • Author
  • December 16, 2019
jerome wrote:

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

Ok .. I understand now how it works.

Thanks . my data is full.


Forum|alt.badge.img
  • Author
  • December 16, 2019
redgeographics wrote:

The RandomNumberGenerator should work, as for the rand() function, you need to make sure you use the Artithmetic editor for that rather than the Text editor, which you have done now.

0684Q00000ArKVIQA3.png

(note the different icon)

The rand() function will result in a random floating point value, if you need integers you'll need to wrap it in an int() function so you'll get 

@int(@rand()*10))

Can you tell us what the output of the RandomNumberGenerator is and what you were expecting?

How to choose a random value in a string list ?


redgeographics
Celebrity
Forum|alt.badge.img+49
jerome wrote:

How to choose a random value in a string list ?

To include a random number in a string attribute you'll need to use the Text Editor and then wrap the function in an Evaluate() function. E.g.

@Evaluate(@int(@rand()*10))

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