top of page

How to Create and Use User-Defined Functions in Power Apps

User-defined functions allow you to create your own PowerFx functions. They can make your app simpler and make your life easier as well!


In this blog, I'll show you how to make sure you can use Power Apps User-Defined Functions in your apps as well as an example to get you started.


SCENARIO - Using Power Apps User-Defined Functions


We want to format numbers as currency, but don't want to have to retype the same function to format the number everywhere.


So...


Let's create our own "CurrencyFormatting" function with User-Defined Functions!


After you understand how this works, you can create your own. :)


Step 1 - Turn this Feature On


  • Make sure your authoring version is 3.24013.10



  • Under "Experimental Features", make sure you have the "New Analysis Engine" turned "ON"


Turning on New Analysis Engine Setting

  • Also under "Experimental Features", make sure you have the "User-Defined Functions" turned "ON"


Turning on Power Apps User-defined Functions


***Note: you may need to reload your app to have these changes take place.***


Step 2 - Create your NEW User-Defined Function


First, here's the syntax for creating a new function:


FunctionName(Parameter:Type, Parameter:Type):OutputType = [Your Formula here]


Now let's use this syntax for our example:


  • In the Formulas property in the "App", enter this formula:


Creating your First Power Apps User-Defined Function

  • Next, add a Text Input control and a Label to your screen

  • Set the Text property of the Label to this:


Use the Power Apps User-defined Function in action

  • See it in action!




Step 3 - Think of Other Formulas for your Apps and Keep Going!


BONUS: Some Ideas for User-Defined Functions use cases:

  • Encapsulate complex calculations or business logic (ex: Pricing models)

  • Validation functions (ex: email or phone number validation)

  • Data Formatting (ex: currency formatting or date formatting)

  • Dynamic default values

  • Filtering and sorting data

  • User permissions

  • Conditional Visibility

  • Error handling

What else can you think of using User-Defined Functions for?


Let us know in the comments. :)


Need help on your Power App or want us to build it for you? Click HERE to contact us, we'd love to help. :)


195 views0 comments

ความคิดเห็น


bottom of page