EVAL


Evaluates the string and returns its value.

Syntax:

EVAL(text)


text is required, and is the string input.


Example:

If text contains "2 + 3":

EVAL("2 + 3")

returns 5


text:


Result:

5

Application:

An application of an EVAL function can be found in a spreadsheet or data analysis program, where it's used to dynamically calculate values from text strings.


Imagine you have a product inventory spreadsheet. You've entered a formula as a text string in one column and now you need to calculate the result of that formula in a separate column.

Product

Price

Quantity

Calculation (as text)

Result (using EVAL)

A
B
C
D
E
1
Laptop
$1,200.00
5
B1 * C1
$6,000.00
2
Monitor
$300.00
10
B2 * C2
$3,000.00
3
Keyboard
$75.00
25
B3 * C3
$1,875.00
4
Mouse
$25.00
50
B4 * C4
$1,250.00

In this example, the EVAL function takes the text from the "Calculation (as text)" column and executes it as if it were a real formula.


For the first row (Laptop):


EVAL("B1 * C1")


The EVAL function would recognize "B1" as a reference to the "Price" column's value (1200) and "C1" as a reference to the "Quantity" column's value (5). It would then perform the multiplication and return the result, 6000.


This is a powerful feature because it allows you to store the logic of a calculation as data and then execute that logic programmatically, rather than hardcoding the formulas for each row.




This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof