Archive

Posts Tagged ‘Power FX’

Power Fx | String Interpolation

If you are familiar with C# language’s string interpolation feature now Power Fx does too.

C# String Interpolation Example:
string name = "Mark";
var date = DateTime.Now;

// String interpolation:
Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");

In Power Fx, use string interpolation to embed formulas within a text string.

This is often easier to work with and visualize the output than using the Concatenate function or & operator.

Splicing a long string with the ‘&’ operator or ‘Concatenate’ function:

  • Following is an example of splicing a string with ‘&’ operator or ‘Concatenate’ function.
"Hello User : " & User().FullName & " Your Email is : " & User().Email // '&' operator
Concatenate("Hello User : ",User().FullName," ;Your Email is : ",User().Email) // 'Concatenate' function

Using Power Fx String Interpolation:

Above String splicing can be easily done using String Interpolation

  • Prefix the text string with a $ and enclose the formula to be embedded with curly braces { }.
  • To include a curly brace in the text string, use repeated curly braces: {{ or }}.
  • String interpolation can be used anywhere a standard text string can be used

$"Hello User : {User().FullName} Your Email is : {User().Email}"

Few more Examples:

$"2+3 = {2+3}"  
// result: 2+3 = 5

$"{{this is inside curly braces}}" // result: {this is inside curly braces}

With( {x:5, y:7},
      $"Point ({x},{y}) is {Text( Sqrt( x^2+y^2 ), "#.###" )} from the origin" )
// result: Point (5,7) is 8.602 from the origin

With( {FirstName: "John", MiddleName: "Q.", LastName: "Doe"},
      $"{Trim( $"Welcome {FirstName} {MiddleName} {LastName}" )}, we're glad you are here!" )
// result: Welcome John Q. Doe, we're glad you are here!

🙂

Power Apps Ideas (Preview)

February 3, 2022 Leave a comment

In this article lets explore the Power Apps “Ideas” feature, which would be a blessing for all App Makers who write formulas using Power Fx.

As we know Power Fx is a programming language for low code, and makes it possible for hundreds of millions of people with Excel-like skills to add advanced logic to their apps.

What is Power Apps Ideas:

Power Apps Ideas is created to help everyone from the new makers to the seasoned IT pros to ease and speed up the formula authoring experience by using the power of AI models.

A quick example:

  • I’ve the following Canvas App with Dataverse as Source. App has a Gallery control displaying ‘Department’ table.
  • ‘Department’ table has a Date Time field called ‘Establishment Date’ and displaying values in MM/DD/YYYY HH:MM format.
  • So what if I want to display ’27/12/2021′ as ’27 December 2021′. You need to form the syntax by yourself which could be tricky.
  • Now lets see, how ‘Ideas’ works here.
  • Select the date label from Gallery and select ‘Ideas’.
  • Go ahead and type the format you are looking for. I’ve typed my desired format as “27 December 2021 5:30 AM“.
  • Now click on ‘Get ideas’ button and you would get the formula for your desired format.
  • Go ahead an click ‘Apply’, you get following notification, that formula expression has got updated.
  • That’s the power of ‘Ideas’.
  • Power Apps Ideas feature currently supports only Gallery and Data table controls for the Items property, and it now supports Microsoft Dataverse, Sharepoint List and Excel as connectors.

Methods to use “Ideas”:

There are two methods to benefit from Power Apps “Ideas” in your app.

Method 1: Transform natural language to Power Fx formulas

Method 2: Transform examples to Power Fx formulas
  • This is nothing but the Date format example, I’ve explained in above sections.
  • With Power Apps Ideas, you can now simply select that field, then in the ideas pane, enter your desired format, and press enter.
  • One or a few formula suggestions will be popped out for you to select from.

🙂

Categories: PowerApps Tags: , ,

[Preview Feature] Model Driven Apps | Edit Command Bar

In this article lets explore the ‘Edit Command Bar’ preview feature available in Model Driven Apps designer. But first lets understand the following basics of Command Bar.

  • What are Command Bars?
  • Where do we find them in Model Driven App (i.e., Command bar locations)?

What are Command Bars?

  • Command bars are at the core of every model-driven app and appear in many different locations.
  • The group of commands associated with a specific location make up a command bar.

Command bar locations in Model Driven App:

  • Main grid. This command bar is displayed when using the left-hand navigation of an app to view a full page list of records in this table.
  • Main form. This command bar is displayed on the table’s main forms. This appears at the top of the form and is not the same as the associated view or subgrid view that will appear in different areas of the form.
  • Subgrid view. This command bar is displayed on forms of other tables that render this table’s data within a subgrid.
  • Associated view. This command bar is displayed on the form of a parent table when viewing related data in this table.
  • Quick actions. There isn’t a specialized entry point from the command designer because quick actions are edited from the main grid of the table.

Now that we got the basics, lets explore editing the Command bar.

Using ‘Edit command bar (preview)’:

  • To use ‘Edit command bar (preview)’ feature. Connect to Power Apps portal.
  • Create a new ‘Model-driven app from blank’ and select the ‘Modern app designer (preview)’.
  • Add a Page and link one of your Dataverse Table.
    • I’ve added ‘Student’ table as Page.
  • Now click on ‘…’ of ‘Student’ and click on ‘Edit command bar (preview)’.
  • From the options choose one of the ‘Command Bar’ location you would like to edit.
  • In the next screen, you will get all the available of Commands displayed as below.
    • At this point editing ‘Legacy button is not supported’. Refer the limitations here.
  • I am going to add a new ‘Command’ named ‘Open My Blog’ which opens up an URL.
  • Click on ‘+New command’ and provide details on the right pane.
  • Action property specifies what happens on the ‘Select’ of the ‘Command’. Below are 2 available options.
  • As I need to open URL on the select of my ‘Open My Blog’ command. Under Action’ choose ‘Run formula’ and in the formula bar add ‘Launch()’ Power Fx as below.
  • Click ‘Save and Publish’ and ‘Play’.
  • On your App, you should see the command and on select it redirects to the provided URL.

Refer the docs link for more details.

🙂

Categories: PowerApps Tags: ,