'Eval() function for Microsoft PowerApps

Is someone aware of an equivalent function in PowerApps that will, just like the Excel Eval() function, take an input string value, execute commands specified within it, and produce a result? For example, if I have I have two variables, varOne already set to the value 1 and a variable x set to 8, and then I fed this Eval() function the following string:

"x + " & varOne & " = " & x + varOne

...it would produce:

"x + 1 = 9"

Does something like this (or a reasonable workaround) exist for PowerApps?



Solution 1:[1]

No, this functionality does not exist in PowerApps at this moment. Feel free to create a new feature request in the PowerApps Ideas board for this.

Solution 2:[2]

There are two ways to achieve this as of the moment.

  1. Create a PCF Control and use JavaScript Eval().
  2. You can use an Api like Math.js or even Bing Search on your Power Automate Flow to solve the equation for you.

Solution 3:[3]

$”x + {VarOne} “ 

This will generate x + 1 as output. You just need to add the Value(x) + Value(varOne) behind it.

It sort of does what you are looking for but not completely. Via logic apps, you can create a JavaScript function and do eval there out of the box. That at least keeps it low code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 carlosfigueira
Solution 2 Crismogram
Solution 3 Iona Varga