Computed Attributes

Andreas2 years ago

Hi,

Can I get some help as to how to perform let's say an addition in computed attributes.
i.e. I have a parameter io24 and io26, and I want to add this 2 parameters and divide the result by 2: How can I enter in the expression: (io24 + io26)/2

Thanks!

Anton Tananaev2 years ago

You enter it the same way as you wrote it:

(io24 + io26)/2
Andreas2 years ago

Thank you so much. It works perfectly ok!

If I may ask one more similar question:
Is there a command for checking a parameter such as: if io178 = 1 this means "2G", if io178 = 2 this means "4G" if io178 = 0 this means "3G"

Thanks

Anton Tananaev2 years ago

Something like this:

io178 == 1 ? "2G" : io178 == 2 ? "4G" : "3G"
Andreas2 years ago

Dear Anton,
Thanks so much for the support.

I tried

io178 == 1 ? "2G" : io178 == 2 ? "4G"

as type: Boolean / Number / String, but in every case it gives me the error:

Invalid parameters or constrains violation:

parse error - ParseException (... < ComputedAttributesHandler:102 < AttributeResource:57 < ...)

Any suggestions?

Anton Tananaev2 years ago

The suggestion would be to use a valid expression, like the one I provided. What you have is invalid.

Andreas2 years ago

Thank you.
Your suggestion works perfectly OK!

Andreas2 years ago

Hi again,

When I do the equation for example: (io24 + io26)/2 the answer is an integer number. Is there a setting or so that can have the number in 1 or 2 decimal places?

Thanks

Anton Tananaev2 years ago

I'm sure there's a way to format it. Check the syntax and API documentation.

Andreas2 years ago

Thanks!

memesaregood2 years ago

Add 0.0 to the result calculation. This will convert integer to double.