Char

How to Use the Power Fx CharĀ  Function in Power Apps

What is the Char Function?

The Char function is a Power Fx function that returns a single character based on its Unicode value. Unicode is a standard system used to represent characters from all the world’s writing systems. Each character has a unique numeric value assigned to it, and the Char function allows you to retrieve the character based on that value.

How Does the Char Function Work?

To use the Char function, you simply need to provide the Unicode value of the character you want to retrieve. For example, if you wanted to retrieve the character “A”, which has a Unicode value of 65, you would use the following formula:


Char(65)


This would return the character “A”. You can also use the Char function with variables or other Power Fx functions to build more complex formulas.

Practical Examples of Using the Char Function

Now that we’ve covered the basics of the Char function, let’s take a look at some practical examples of how you can use it in your Power Apps projects.

1. Creating Dynamic Labels

One common use case for the Char function is to create dynamic labels that change based on user input. For example, let’s say you have a form where users can select their gender, and you want the label for the gender field to change based on their selection. You could use the Char function along with an If statement to achieve this:


If(

GenderComboBox.Selected.Value = "Male",

"Male " & Char(9794),

"Female " & Char(9792)

)


In this example, we’re using the Unicode values for the male and female symbols to dynamically update the label based on the user’s selection.

2. Formatting Text in a Data Table

Another way to use the Char function is to format text in a data table. For example, let’s say you have a table of data that includes a column for status, and you want to display a checkmark next to each row where the status is “Complete”. You could use the Char function along with the If and Concat functions to achieve this:


ForAll(

Table1,

{

Text: Status,

Icon: If(

Status = "Complete",

Char(10003),

""

)

}

)


In this example, we’re using the Unicode value for the checkmark symbol to display a checkmark next to each row where the status is “Complete”.

3. Customizing Button Icons

Finally, you can also use the Char function to customize the icons on Power Apps buttons. By default, Power Apps includes a set of built-in icons that you can use on your buttons, but if you want to use a custom icon, you can use the Char function along with the Concat function to achieve this:


Button1.Icon = Concat(Char(9733), Char(9733), Char(9733), Char(9733), Char(9733))


In this example, we’re using the Unicode value for the star symbol to create a custom icon for Button1.

The Power Fx Char function is a powerful tool for manipulating text in Power Apps. By understanding how it works and some practical examples of how to use it, you can take your Power Apps projects to the next level. Give it a try in your own projects and see what you can create!

Power Apps Training Courses by G Com Solutions (0800 998 9248)