Published on

Value

Authors
  • avatar
    Name
    Jason Deramo
    Twitter

It's been a while since I wrote any code-related posts, so I pulled a function at random within the Power Fx library. For example, the Value function converts a text string (sequence of characters) to a numerical expression. You'll want to use this when performing calculations on numbers entered as text. These functions can also convert other data types to numbers, such as date/time or Boolean.

Example: Converting a Date String

The following example converts a date from a string and shows the result as a long date:

Set(varDate, Text(Today(), DateTimeFormat.LongDate))

If entered properly, the output reflects the current date/time.

Using the Collect Function with Button Input

Here is another example using the Collect function triggered by a button:

Collect Function Example

Versatility of Value

Converting string-to-number values can extend to mathematical formulas, boolean (true/false), and other complex formulas within your given scenario. Unlike in Python, where the values() method returns a view object in a dictionary, the Value function strictly involves numerical outputs and text conversion.

Reflections

In a human sense, value is also what one ascribes to something of supreme worth. Often, the greater the value, the larger the sacrifice given. Whether in coding or life, it's ultimately the price one has to offer in exchange that truly makes something precious. Such sentiments were beautifully conveyed by Jesus when describing the value of faith in operation:

The kingdom of heaven is like treasure hidden in a field. When a man found it, he hid it again, and then in his joy went and sold all he had and bought that field. Again, the kingdom of heaven is like a merchant looking for fine pearls. When he found one of great value, he went away and sold everything he had and bought it. — Matthew 13:44-46 (NIV)

AI-Generated Image

AI-Generated (DALL-E©)