Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Commonly used Power Fx Functions for Model-Driven Apps

Commonly used Power Fx Functions for Model-Driven Apps

In Model-Driven Apps, Power Fx is less prominent compared to Canvas Apps, as much of the logic is handled by the data model and business rules. However, when used, it often involves similar functions:

There are two areas in model driven app where you can use PowerFX. One area is in Command button action and another is Formula Column.

Text: Converts a value to text.

Text(Number(123.45))

Value: Converts a text string to a number.

Value("123.45")

Concatenate: Joins two or more strings into one.

Concatenate("Hello", " ", "World")

Now: Returns the current date and time.

Now()

Today: Returns the current date.

Today()

DateAdd: Adds days, months, quarters, or years to a date/time value.

DateAdd(Today(), 5, Days)

Sum: Calculates the sum of a table of numbers.

Sum(Table({Value: 1}, {Value: 2}, {Value: 3}), Value)

Round: Rounds a number to the specified number of decimal places.

Round(123.456, 2)

If: Evaluates a condition and returns one value if true and another if false.

If(Value("123.45") > 100, "High", "Low")

Switch: Matches a value against a list of values and returns the corresponding result.

Switch(Text(2), "1", "One", "2", "Two", "Other")

LookUp: Finds the first record in a table that matches a condition.

LookUp(Accounts, AccountNumber = "A123")

Filter: Filters a table based on a condition.

Filter(Accounts, City = "Seattle")

AddColumns: Adds calculated columns to a table.

AddColumns(Accounts, "AccountValue", AccountBalance * 1.1)

RenameColumns: Renames columns of a table.

RenameColumns(Accounts, "oldName", "newName")

Check property of a related record

Self.Selected.Item.'Parent Account'.'Account Name'="parent"

Access 1:N property

Self.Selected.Item.'Recurring Appointments'

Launch a URL

Launch("https://www.bing.com");

Notify the user

Notify( "Model-driven app notification message" )

Ask for confirmation before taking action

Notify( Confirm( "Are you sure?", 
                 { ConfirmButton: "Yes", CancelButton: "No" } 
        ) 
)

Current user has permission

EditButton.Visible = 
   RecordInfo( Gallery1.Selected, RecordInfo.EditPermission );
   CreateButton.Visible = 
   DataSourceInfo( Accounts, DataSourceInfo.CreatePermission )

Navigate to the default form of the table in create mode

Navigate( Defaults( Accounts ) )

Navigate to the default form of the table

Navigate( Gallery1.Selected )

Navigate to specific system view of the table

Navigate( 'Accounts (Views)'.'My Active Accounts' )

Navigate to the default view of the table

Navigate( Accounts )

Navigate to a custom page

Navigate( myCustomPage )

Control visibility based on record data

//Button will be visible for accounts with Account Rating > 20
Self.Selected.Item.'Account Rating'>20

Visible property: Only show the command if one or more records is selected in a grid view

CountRows(Self.Selected.AllItems) > 0

Check and edit a date property

If(Self.Selected.Item.'Last Date Included in Campaign'>DateAdd(Now(),-3), Patch(Accounts,Self.Selected.Item,{'Last Date Included in Campaign':Date(2021,10,19)}))

Create a related record

Patch(Tasks,Defaults(Tasks),{Regarding:Self.Selected.Item},{Subject:"Subject of the Task"})

Patch (update) the current selected record

Patch(Accounts, Self.Selected.Item, {'Account Name': "Changed Account name"})

Functions not supported

The following Power Fx functions are currently not supported with commanding in model-driven apps.

  • Back()
  • Clear()
  • Collect()
  • Copy()
  • Disable()
  • Enable()
  • Exit()
  • InvokeControl()
  • Language()
  • LoadData()
  • Param()
  • ReadNFC()
  • RequestHide()
  • ResetForm()
  • Revert()
  • SaveData()
  • ScanBarcode()
  • Set()
  • SubmitForm()
  • UpdateContext()
  • User()
  • ViewForm()
  • Align
  • AlignInContainer
  • BarcodeType
  • BorderStyle
  • Color
  • Direction
  • DisplayMode
  • Font
  • FontWeight
  • FormPattern
  • GridStyle
  • ImagePosition
  • ImageRotation
  • LabelPosition
  • Layout
  • LayoutAlignItems
  • LayoutDirection
  • LayoutJustifyContent
  • LayoutMode
  • LayoutOverflow
  • ListItemTemplate
  • MapStyle
  • Overflow
  • PDFPasswordState
  • PenMode
  • RemoveFlags
  • ScreenTransition
  • TeamsTheme
  • TextFormat
  • TextMode
  • TextPosition
  • Themes
  • Transition
  • VerticalAlign
  • VirtualKeyboardMode
  • Zoom
  • Acceleration
  • App
  • Compass
  • Connection
  • Dataverse file type columns
  • Environment
  • Host
  • Layout
  • Location
  • ScreenSize

Hope it helps.