Close menu

Number Data

Jumbled chaotic mess of numbers in every space of the image (foreground, middle ground, and background), with the top of the image containing the phrase Number: Something reliable to count upon

The number data type is oh so useful, let me just count the ways! I kid, but not about the usefulness. This post is about numbers, but I want to clarify that I’m only talking about whole numbers (or integers), decimals, fractions, floating point, and currency, both positive and negative. According to the Microsoft documentation, the Number data type is:

A floating-point number.

Microsoft Learn Documentation

And the Currency data type is:

A currency value that’s stored in a floating-point number. Currency values are the same as number values with currency-formatting options.

Microsoft Learn Documentation

So, what does all that mean? Basically, a Number is:

  • any numeric value not used within quote characters,
  • positive or negative,
  • with or without a decimal point, and
  • up to 8-digits of precision, or number of digits past the decimal.

And Currency is also a number, just make it fancy! 😅

Math got us into this mess, and it's math that will get us out!

All the standard arithmetic operators apply in Power Apps (so don’t forget PEMDAS, or the other variations of it, from introductory Algebra):

P ( ) Parentheses, aka Brackets, are used for grouping, and setting the order by which your numbers are manipulated.
E ^ Exponents are applied to anything inside parentheses only after the inside has been calculated. If there are exponents inside your parentheses, then calculate the exponents inside the parentheses.
M & D * & / Multiply and Divide:

  • These two are applied equally from left to right, and are not prioritized based on their function.
  • This means that in an equation (say… a / b + x * y / z) the multiplication is not prioritized over the division, they each happen sequentially.
  • So, for our example, a is divided by b, and x is multiplied by y then divided by z.
A & S + &  Add and Subtract:

  • These two are also applied equally from left to right, and not prioritized based on their function.

Math is math, why the lesson?

When you start to use Power Apps, you may find yourself using simple math functions. That is fine and perfectly acceptable. However, when you start to build more complicated apps, you need to understand how the system will follow your logic. This is where PEMDAS comes into play.

You may hear the term ‘nested‘ or ‘nesting‘ when more than one formula is used. This simply means one formula is contained within another, which can happen many multiple times. I don’t recall where I came across this, but somewhere I heard that best/good practice is no more than three (3) layers of nesting, to assist with troubleshooting and readability.

For the Excel users with me right now, I’ve got a couple fun facts for you:

  • The Power Fx formula language was built on the foundation created by Excel functions.
  • The formula bar is the same concept as used in Excel, but it’s been Powered-up for use in Power Apps.

What I mean by this is, that in Power Apps you can:

  • Connect your various data sources right in your formulas.
  • Include comments describing the intent of the formula or function, or even comment out one or more lines for testing purposes.
  • Chain together multiple formulas through the use of the semicolon (;).

The example shown below is for a Radio button On Select property. When the Selected ID equals 4, Form1 will be reset, and then the button will be reset to the default value.

Screenshot of the Power Apps Formula bar showing inline commenting and formula chaining with the use of the semicolon (;).
Screenshot of the Power Apps Formula bar showing inline commenting and formula chaining with the use of the semicolon (;).
0 0 votes
Post Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

[…] use your single array for both required arguments in the function. This works with numbers, text, and even records/objects (like items from a SharePoint List […]

1
0
Would love your thoughts, please comment.x
()
x