Skip to main content

Notifications

Announcements

No record found.

Generating Power Fx Formulas with Multi-Language Comment Support in Power Apps Using Copilot

Inogic Profile Picture Inogic 24,083

​​​​​​​The Comment-Generated Formulas feature in Power Apps lets you create Power Fx formulas directly from code comments. By typing `//` or ‘/*’ followed by a natural language instruction, Copilot can generate a relevant Power Fx formula tailored to your app’s context. You can choose to accept Copilot’s suggestion or edit the formula, using comments as convenient documentation for each formula.

This tool is now available and supports multiple languages beyond English, making it accessible for users worldwide. Languages like French, Spanish, and German are now supported, allowing you to direct Copilot in your preferred language. To see the list of supported languages, refer to the official documentation on Supported Languages.

Prerequisites

Copilot must be enabled in your environment. For additional guidance, refer to the documentation on how to enable or disable Copilot in Power Apps.

The new formula bar is enabled by default. If the Copilot menu isn’t visible, review your app settings in Power Apps Studio:

  • In the command bar, go to Settings.
  • Now navigate to Updates, and enable the option for Copilot comment-generated formulas.

Generating Power Fx Formulas

  • In the “Retired” tab, disable the toggle for “Legacy formula bar.”

With these settings, you’ll be ready to take full advantage of Copilot’s AI-powered formula generation in Power Apps, simplifying formula creation with natural language.

Generating Power Fx Formulas (1)

Create Power Fx Formulas Instantly from Comments

In Power Apps, Copilot allows you to generate Power Fx formulas directly from comments entered in the formula bar. Simply type a comment using `//` or `/*`, and Copilot will suggest a formula based on your comment.

  1. Open your Canvas app in edit mode.
  2. Type a comment in the formula bar by starting with `//` or `/*`.

Example: // Calculate total expenses

  1. Give Copilot a moment to suggest a formula, or press “Enter” to create it immediately.

In the example below, I’ve created an expense calculator app in Power Apps and used a code comment to generate a formula to calculate pending expenses.

Example Code Comment:

// Concatenates a dollar sign with the formatted sum of costs from the LineItems2 table where the ReportID is found in the PendingReports table, but only if that sum is greater than zero; otherwise, it shows zero.

Generating Power Fx Formulas

AI-Generated Formula:

If(Sum(Filter(LineItems2, ReportID in ShowColumns(PendingReports, ID)), Cost) > 0, “$” & Text(Sum(Filter(LineItems2, ReportID in ShowColumns(PendingReports, ID)), Cost), “$#,##0.00”, “en-US”), “$0”)

To use the suggested formula, press ‘Tab’ to accept it. You can continue typing to adjust the formula as needed.

Generating Power Fx Formulas

If Copilot doesn’t offer a suggestion, it means it couldn’t generate a formula based on your comment. Try rephrasing the comment to improve results. It’s recommended to enclose elements you want to include in your formula in quotes, such as “PendingReports.ID” and “LineItems2”.

Now Available with Multi-Language Support

The Generating Power Fx formula using Copilot now supports multiple languages! To see the list of supported languages, refer to the official documentation on Supported Languages.

Let’s try the example in Spanish:

Example Code Comment:

// Concatena un signo de dólar con la suma formateada de costos de la tabla LineItems2 donde el ReportID se encuentra en la tabla PendingReports, pero solo si esa suma es mayor que cero; de lo contrario, muestra cero.

By using this comment in Spanish, Copilot generated the same formula as in the original example.

Generating Power Fx Formulas

Some limitations when generating formulas from code comments:

  1. It works only on the specific control and property you are focused on, and won’t modify other controls or properties to achieve the desired result.
  2. Copilot doesn’t consider any existing formula text that is already present.
  3. It only recognizes the default properties in Power Apps, and are limited to supporting general Power Fx functions.
  4. User-defined functions are not recognized by Copilot.
  5. Functions specific to Power Apps, like `Navigate()`, aren’t supported in code comments.… Read More »​​​​​​​

This was originally posted here.

Comments

*This post is locked for comments