Transform natural language to Power Fx formulas

Introduction:

We all know that to make an app powerful, you must first deal with Power Fx formulae to link objects together, such as saving forms, searching, updating UI based on button clicks or content input in a text control, and so on. And you don’t have to be a pro-developer to start building Power Fx formulas. Nonetheless, some time is still required when attempting to build a formula, such as determining which function to use and what syntax to implement, as well as modifying and improving.

Power Apps Ideas can generate formula ideas by utilizing the following controls on different properties:

  • Gallery
  • Data table
  • Text Box
  • Drop Down
  • Combo Box
  • Text Label

As connections, Power Apps Ideas also supports Microsoft Dataverse, Microsoft Lists, SharePoint library, and Excel. Check out Power Apps Ideas if you’re using one of the available controls and wish to write a formula for Gallery or Dropdown items, or for Label’s text content, color, or visibility.

In the following example, experienced developers can easily write the following formula to allow users to use the search box to search customers by name and sort results.

That is, they must at least understand.

  • What the Search() function can achieve and how to use it
  • The Sort() function, what it can accomplish, and how to use it
  • How to Use Power Fx’s Text Input Value
  • In Dataverse, knows the logical term for Full Name.

For example, instead of attempting to write the following formula…

Filter(‘Table1’, StartsWith(‘fullname’, “Yvonne”))

… You can type ‘name starts with Yvonne instead.

To begin, let’s have a look at a simple program to demonstrate how Power Apps Ideas may help you write formulas.

To construct that app using Dataverse’s Accounts database, follow the procedures described in Develop a canvas app from Microsoft Dataverse.

  • Choose BrowseGallery1, which is associated with the Accounts table.
  • On the suggestions box, select Sort, filter, and search.
  • Choose one of the preset choices to see how it works or begin typing your own question in natural language such as English (en-us).
  • You can use the default query, edit it, or explain it in your own words while typing.
  • One or more formula ideas will be generated. Let’s look at an example of a search accounts where name in textinput. The results will show two suggestions. Each of those formula suggestions has three components:
    • Accounts with the text TextInput1 in the name. This is an attempt to describe what the proposed formula does so that users unfamiliar with Power Fx can understand the outcome. The names of the app’s components are shown in bold.
    • Apply to: Items: This specifies the property the formula will be applied to. Ideas can determine which property a formula should be applied to because Power Apps controls have several properties.
    • In this case, the formula recommendation is Search(‘Accounts’, TextInput1.Text, “name”).
  • Choose your best idea and then click Apply. In this scenario, we’ll go with the first proposal because it’s the best fit. The formula is automatically updated and executed, allowing you to view the results in your app. You can then choose whether to keep or modify the chosen formula.

Additional Examples

While working with Power Apps Ideas, consider the following samples for inspiration.

ScenarioDescriptionIdeas example
Sort your tableSort by a single columnsort accounts by Account Name
sort accounts by Account Name A-Z
sort accounts by Account Name Z-A
Sort accounts by Account Name and Created Onsort accounts by Account Name A-Z and Created On latest on top
Sort existing tablessort Gallery3 by Account Name Z to A
Filter or search table by some conditionsA number conditionaccounts with length of Account Name bigger than 10
A date conditionaccounts created a week ago, accounts modified last 3 days
A text conditionaccounts with name contains Karen
A few conditionsaccounts whose name contains Karen and created 7 days ago
A choice valueinactive accounts
Search table by user inputsearch accounts with name in textinput
Find a single recordfirst record in accounts where name contains Karen
Find records on the top or the bottom of the tabletop 10 accounts
last 10 accounts
Conditional formatting (apply to color and visible)A number conditionaccounts with length of Account Name bigger than 10
A date conditionred if created 7 days ago
A text conditionblue if name contains Karen
Text generationNumberscount of gallery sum of slider1 and slider2
Stringlabel4 and label5 Trim textinput1First 3 characters of TextInput1

Good Practices

Use these suggestions when constructing the basic natural language question in the Ideas window to receive the best results.

  • Use default queries to determine what kind of scenarios are supported.
  • Make your enquiry as specific as possible. Controls such as tables and columns can be recognized by ideas. If you don’t receive a suggestion, try mentioning the entire name of the assets you’re referring to. When you have many text input controls in your app, for example, use TextInput1. This allows the system to determine which control you’re referring to.

Limitations:

The following are the current limits of Power Apps Ideas:

  • Regions and language: English (en-us) is currently configured as the browser’s default language in environments developed within the United States.
  • TextInput, Dropdown, DatePicker, Slider, Toggle, Checkbox, and Radio control values are recognized as input.
ControlsProperties
Gallery, Data table, Drop down, Combo boxItems
Text Box, LabelText, Color, Visible
  • Data sources: Ideas currently supports Dataverse tables, Microsoft Lists, and Excel sheets.
  • Functions: Check the list of supported Power Fx functions. We will continue to provide support for additional functions.
  • Supports Text, Whole Number, Date and Time, Date Only, Decimal Number, Choice, Choices, and Yes/No Lookup as data types. File and Image are not supported.
  • The model for this feature understands certain regularly used natural language expressions. It can, for example, translate from latest on top, big to small in descending order to oldest on top, small to big in ascending order. And because it understands much of the context, it will make the best forecast based on the current table that is connected to the control even if you don’t mention the table names.

Supported Power Fx functions.

The Power Apps Ideas feature supports the following functions:

References: –