May 17, 2024

Power Fx and what I mean for low-code

Power Fx is one of the programming languages available inside Power Platform, the Microsoft documentation reports:

Power Fx is the low-code language that will be used across Microsoft Power Platform.

It's mostly used inside Canvas Apps but inside a canvas app it's very difficult for me to call it "low-code", if there is a function called "Explain This Formula" inside Copilot (link) it usually means it's hard to read or people tend to write complicated code that is not readable.

Being a developer probably for me it's easier to read some C# code than some Power Fx formula connected to items inside a canvas app where fields are referenced with the display name.

However there is another part where Power Fx is used inside Power Platform: the possibility to create new Formula columns inside Dataverse, in my opinion this is a very powerful tool at our disposal.

Years ago I created this PCF: Custom Url Control
The idea behind the PCF was simple, to create a clickable url with data coming from the record.

The same thing these days can be done with a Formula column writing a simple Power Fx formula.

Let's assume you have two columns inside a table: Code (text containing the tracking code) and Company (choice with the couriers, in my example USPS and UPS)

We want to create a URL column so when the Company is USPS the link is:
https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=[Code]
and when the Company is UPS the link is:
https://www.ups.com/track?tracknum=[Code]

This column can be a Power Fx formula using a Switch statement:

Switch(Company, 'Company (Shipments)'.USPS, "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=" & Code, 'Company (Shipments)'.UPS, "https://www.ups.com/track?tracknum=" & Code )

In this case the first parameter of the Switch operator is the column we are checking: our Company column.
The following parameters needs to be considered by two: Match and Result.
Match in our case is the choice value (USPS) and the Result is the URL we want, the first part is fixed (the USPS website) and after is concatenated the Code.
You can also see the second couple (UPS choice and UPS website).

The result in a model-driven app form is the following:



The main advantage? The value of this column is available everywhere: inside a model-driven app, a canvas app, a Power BI report, a Power Automate flow, etc etc.

This is in my opinion a good example of low-code, you wrote something simple, understandable but very powerful, years ago for the same requirement you needed to create a PCF, before that probably a C# plugin, now just a short Power Fx formula.

0 comments:

Post a Comment