Round value to predefined ranges

Hello,

How can I set a value to some predefined ranges. For example I have a key “number” with a value of 13400. I want Alumio to set a new key called “numberFilter” where the value should be 20000.

The “numberFilter” key should be restricted to the following values: 0, 20000, 40000, 60000, 80000, 100000, 120000 and 140000. A value from “number” should be round up to the nearest value. If a value is above 120000, it should always be 140000.

Is this possible with Alumio transformers?

Thanks in advance!

Hi @yoeri,

Is the key “numberFilter” reusable in other parts of the transformer? If not, we suggest using a Value Setter in combination with “Dictionary Map” to set the value of key number, as shown below.

You can add more maps there based on the values, for example:

  • number 40000 to number 60000
  • number 60000 to number 80000
  • number 80000 to number 100000
  • and so on

By choosing “Greater than” as the comparator, it will update, for example, value 1 to 20000 or 27500 to 40000.

Please let us know if this is not the case.

Hi @Gugi,

Thank you for your reply. I tried to set this up, but in the transformer tester it doesn’t work as expected.

Is there something I do wrong?

Hi @yoeri,

We are sorry if the previous advice doesn’t work. Apparently, we should start the map from the biggest one to the lowest one, such as below.

Please give it a try.

Hi @Gugi,

Yes, this is working. Thanks!

1 Like