web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Field reference contex...
Power Apps
Answered

Field reference context in functions.

(0) ShareShare
ReportReport
Posted on by 171

Functions that work with record and table values expose their fields within the function.

eg.

If I have a collection

 

Collect(myCollection, {field1:"value1", field2:"value2", field3:"value3"});
Collect(myCollection, {field1:"value4", filed2:"value5", field3:"value6"})

I can perform a function on it and use the field names in the evaluation

 

 

LookUp(myCollection, field1="value1")

Where 'field1' is a field in the record or collection being evaluated.

This seems simple but is there a way to provide context for these feilds when multiple collections are being evaluated in nested functions

 

eg

If I have these two collections

 

Collect(myCollection, {field1:"value1", field2:"value2", field3:"value3"});
Collect(myCollection, {field1:"value4", filed2:"value5", field3:"value6"});

Collect(otherCollection, {field1:"valueA", fieldB:"valueB", fieldC:"valueC"});
Collect(otherCollection, {field1:"valueD", filedB:"valueE", fieldC:"valueF"})

Now I want to perform the following function

ForAll( myCollection,
 ForAll( otherCollection,
 Collect(newCollection,
 {newField1 : field1,
 newField2 : field1,
 newField3 : field2,
 newField4 : fieldB}
 )
 )
)

Notice I have assigned 'field1' to both 'newField1' and 'newField2'

What I really want is

newField1 : myCollection.field1
newField2 : otherCollection.field1

But I cant find any documentation on how to provide the context of the collection I am refering to.

 

I know there are better ways to perform this example function, it is only for illustration.

In production need to use a variety of other nested functions to decide what to to with the records being iterated through.

 

Any suggestions would be appreciated.

 

 

Categories:
I have the same question (0)
  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    Currently there's no way to determine which context you're accessing - please consider creating a new feature request in the PowerApps Ideas page for that.

     

    Look at @Meneghino's post for the answer.

     

    Another alternative is to rename one of the columns that have the same name, so that there is no conflict:

    ForAll( myCollection,
     ForAll( RenameColumns(otherCollection, "field1", "oc_field1"),
     Collect(newCollection,
     {newField1 : field1,
     newField2 : oc_field1,
     newField3 : field2,
     newField4 : fieldB}
     )
     )
    )

     

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    Hi @SimonMeadows, and apologies for contradicting @CarlosFigueira, but I normally use the disambiguation operator and it works fine for such cases.

    Or have I missed something?

    Thanks.

  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    Please don't apologize, I wasn't aware that operator could be used in such cases, thanks for teaching me something new 🙂 As @Meneghino mentioned, this expression should work:

    ForAll( myCollection,
     ForAll( otherCollection,
     Collect(newCollection,
     {newField1 : myCollection[@field1],
     newField2 : otherCollection[@field1],
     newField3 : field2,
     newField4 : fieldB}
     )
     )
    )
  • SimonMeadows Profile Picture
    171 on at

    Thanks @Meneghino

     

    I had a feeling it would be at the bottom of a documentation page somewhere, I just couldn't find it.

    Smiley Very Happy

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard