Table of contents
I thought a post about text data would be easy to write up, and I was wrong. I have struggled with writing and re-writing this post. Mostly because of the simplicity of this data type mixed with the complexity of manipulating it. Regardless, I do want to start with the definition from Microsoft. According to the documentation, the text data type is defined as…
A Unicode text string.
For someone that might not know what data types are, this can definitely lead to more questions than answers. Hopefully, this post helps to make text data a bit clearer.
- The first thing I want to clarify is that text, text strings, and a string all roughly mean the exact same thing.
- Each refers to a combination of letters, numbers, symbols, and/or spaces all enclosed within quotes.
- The second, is that each item of a string of text is known as a character.
- Each character has an associated code value, usually between 0 and 255.
- Any character with a code value greater than 255 is known as a Unicode character.
Some quick examples of this data type are:
- “Hello world!”
- “Hi there, friend!π”
- “1, 2, 3, 4, and 5”
- “ααα’”
Things to do to Strings
First off, the simplest thing to be done with a text string is to change its formatting. For a label control in Power Apps, there are each of the following format properties:
- Font Name, Size, Weight (boldness value)
- Italics, Underline, or Strikethrough
- Vertical and Text (or horizontal) Alignments
- Wrap, for visibly breaking long text across multiple lines.
- Line height, aka spacing between each line of text. Line height becomes more obvious when the text it is wrapped.
- Top, Bottom, Left, and Right Padding, or the space around the outside of the text.
- Color (of the font), Fill (color of the background), and Border Style, Sizes (or width), and Colors
- With additional versions of these properties for when the label is Disabled, Pressed (clicked-on), or Hovered over.
Each properties has the ability to be dynamically controlled by actions within the app, or based on the values of one another, but that’s for another post. What we’re here for in this moment is the string of text that would be formatted by the properties above.
You could very well enter a plain vanilla string into the Text property. At the end of the day, that might be all that is needed of this label, and that’s perfectly fine. However, there is going to be a time where the text displayed on your app needs to change based on:
- the User’s information;
- to give context to the user about what they need to do next; or
- to let the user review what they’ve done up until this point.
String Manipulation
One key concept to know about strings is concatenation, which is the joining of two or more strings together as one. This can be accomplished in a variety of ways within Power Apps including the:
- Ampersand (&) character which joins together the text strings that come before and after it.
- Concatenate() function, which requires a list (separated by commas) of each string of text to join together.
- Concat() function, which requires a table of records, a value to join from each record, and a delimiting (or separating) character/set of characters for use between each record value.
An additional concept of concatenation that is used in Power Apps is known as String Interpolation. This technique helps to form more easily readable, dynamic strings. Below are the key points regarding this technique:
- The text string must start with a dollar-sign ($) character before the opening double-quotes.
- Close the text string with another set of double-quotes.
- When inserting any dynamic text, enclose functions, variables, or calls to a value between an open curly-bracket ({) and closed curly-bracket(}).
More posts on text strings and manipulating them to come, but for now I thought this should suffice for getting someone started.
[…] 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 […]