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 / Nested lookup - delega...
Power Apps
Answered

Nested lookup - delegation

(2) ShareShare
ReportReport
Posted on by 127

Hi All,

 

I have 3 SharePoint lists that are related via their IDs, as an example I have created a sample dataset below.
Example.PNG

Based on an item from SP List 3 (in a gallery), I would like find the corresponding company from SP List 1.

 

A nested lookup, such as the one below, results in a delegation warning. 

Lookup('SP List 1', ID1 =Lookup('SP List 2', ID2 = ThisItem.ID2).ID1).Company

 

Is it viable to breakup the lookup into two parts to avoid the nested lookup? For example, store the inner lookup result as a variable and then use that variable within the outer lookup.

 

eg: 

Step 1: Updatecontext({var_LookUpResult:Lookup('SP List 2', ID2 = ThisItem.ID2).ID1})

Step 2:Lookup('SP List 1', ID1 =var_LookUpResult).Company

 

Based on my testing in Power Apps, this appears to work, but I am wondering if I have missed any potential issues/complications that could arise from doing this loophole. 

 

Thank you in advance for your help.

 

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Tono_Analyst2 

     

    To get Company Info 

    With({_item:LookUp(SPList2, ID2=ThisItem.ID2)},
    LookUp(SPList1, ID1=_item.ID1).Company)

     

  • Tono_Analyst2 Profile Picture
    127 on at

    Thank you for your response @StalinPonnusamy .

     

    Your solution does look more elegant and I will take that onboard to implement. 

     

    Out of curiosity, would my method of storing a lookup variable for another lookup have any negative effects? 

     

    Thank you

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Nope. This is the right way to implement.

  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Tono_Analyst2 

     

    I just made a quick test and here is the same for reference

     

    With(
     {
     _item: LookUp(
     EventIItinerary,
     ID = ThisItem.SingleEvent.Id
     )
     },
     With(
     {_item2: Addresses},
     LookUp(
     _item2,
     ID = _item.Address.Id
     ).Address1
     )
    )

    SPList 1: IssueTracker (Gallery)

    SPList 2: EventIItinerary

    SPList 3: Address

     

    • IssueTracker has Lookup to EventIItinerary (field: SingleEvent)
    • EventIItinerary has a lookup to Address
    • In this example retrieving Address1 from SPList 3

     

    StalinPonnusamy_0-1633749231670.png

    StalinPonnusamy_1-1633749251526.png

    StalinPonnusamy_2-1633749269407.png

     

    Let me know if any questions

     

     

  • Tono_Analyst2 Profile Picture
    127 on at

    I found that the delegation warning appeared depending on how I set up the with statement:

     

    This Caused Delegation warning (in blue):

    With({record: Lookup('SP List 2', ID2 = ThisItem.ID2)},    Lookup('SP List 1', ID1 =record.ID1).Company)

     

    This Did not cause delegation warning: 

    With({record: Lookup('SP List 2', ID2 = ThisItem.ID2).ID1},    Lookup('SP List 1', ID1 =record).Company)

     

    I am not sure if the second set up is still not delegable, but power apps is just not detecting it...

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    I'm sure you noticed, I'm using 2 with statement to avoid delegation

    With(
     {
     _item: LookUp(
     EventIItinerary,
     ID = ThisItem.SingleEvent.Id
     )
     },
     With(
     {_item2: Addresses},
     LookUp(
     _item2,
     ID = _item.Address.Id
     ).Address1
     )
    )

     

  • Tono_Analyst2 Profile Picture
    127 on at

    Yes, I did notice and that appears to work for me - thank you for your help.

     

    I noticed that if I specified the field within the with statement, it also did not cause a delegation warning

    With({record: Lookup('SP List 2', ID2 = ThisItem.ID2).ID1},    Lookup('SP List 1', ID1 =record).Company)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard