Skip to main content

How to Use the As Operator in Power Apps

· 3 min read
Jagdish Kumawat
Founder @ Dewiride

Functions such as Filter, AddColumns and ForAll work through a table one record at a time, and inside them ThisRecord is the current record. Put one of those functions inside another, and ThisRecord means the inner one only. As gives a record its own name, so you can reach it from anywhere in the formula.

Syntax​

Syntax
Table As Name

As overrides ThisItem and ThisRecord with a name you choose. It works in a gallery's Items and in record-scope functions such as ForAll, Filter, With and Sum (ThisItem, ThisRecord, and As operators).

Why You Need It​

Microsoft explains: when record-scope functions are nested, ThisItem and ThisRecord always refer to the innermost scope, and records in the outer scopes become unavailable. As makes them available again.

Example: A LookUp Inside AddColumns​

In the Career Development Plan app, each competency (outer table) needs the matching response (inner table). Both tables have a Level column:

galMyPlanMPS → Items
AddColumns(
locMyPlan As planItem,
StatusText,
Switch(
LookUp(
locMyResponses,
RoleCompetencyId = planItem.ID && Level = planItem.Level.Value
).Status.Value,
StatusPending, "Waiting for review",
StatusApproved, "Approved",
StatusDeclined, "Declined",
"Not started"
)
)

Inside the LookUp:

  • Level and RoleCompetencyId are columns of the response being checked, the inner record.
  • planItem.Level.Value and planItem.ID are columns of the competency, the outer record, reachable only through its name.

The expanded formula bar showing AddColumns with RoleCompetencies As planItem and planItem.ID and planItem.Level.Value inside the LookUp, Data type Table, and the gallery rows each showing a Not started badge

The As here belongs to AddColumns, so the gallery's own controls still use ThisItem, for example ThisItem.StatusText.

As in a Gallery's Items​

Put As at the top level of a gallery's Items, and the template uses that name instead of ThisItem. Microsoft's example is Employees As Employee, with Employee.Picture in the template.

Common Mistakes​

MistakeWhat happensDo this instead
Using ThisRecord to reach the outer recordIt refers to the inner oneName the outer record with As
A name that's also a column nameConfusing formulasPick a distinct name, such as planItem

Troubleshooting​

SymptomLikely causeFix
A comparison inside a LookUp always fails or always matchesBoth sides read the same recordName the outer record with As
The name isn't recognizedIt's used outside the function that defines itUse it only inside that function

FAQ​

Is As required?​

Only when you need an outer record from inside a nested function. Elsewhere it's optional, but it can make a formula easier to read.

Can I use As more than once in a formula?​

Yes. Give each scope its own name, as Microsoft's nested ForAll example does.

Conclusion​

Table As Name gives the current record a name of your choice. Use it whenever a function inside another needs the outer record, as in a LookUp inside AddColumns.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.