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 / Using global variable ...
Power Apps
Answered

Using global variable to set lookup list

(0) ShareShare
ReportReport
Posted on by

Hello All,

 

Can I use a global variable to reference a list?

In the incomplete code below 'Prod' is a global variable where it should be a reference to a SharePoint list.

Is it possible to get this sort of function so I can access which ever list my variable points to?

LookUp(Prod, 'Batch ID'= BatchIDRePos.Text

 

Thank you in advance.

 

Rob 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @rob4681,

     

    As long as both lists contain the column 'Batch ID', the function will not throw an error. Please note that by using a variable you are no longer pointing directly to your datasource but rather a local copy of the records stored within a variable (similar to a collection). Storing your rows in a variable or collection is non-delegable, meaning you can only store up to the Data Row Limit defined in your app settings.

     

    'Dynamically' referencing your datasource (or e.g. a column) is generally done by using a Switch statement:

    Switch(
     varDatasource,
     "Prod1",
     LookUp(TableProd1, 'Batch ID' ...),
     "Prod2",
     LookUp(TableProd2, 'Batch ID' ...)
    )

    This set-up would still allow the Look-Up to be delegable (if your condition is delegable). Both the variable and Switch approach require that the columns you would like to access have the same name in both datasources (the column schema must match). If a small number of columns are different, you could map these with the AddColumns function.

     

    When the datasources have completely different schema's, you may want to use separate galleries with conditional visibility. However, be mindful of app performance when choosing this approach.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • rob4681 Profile Picture
    on at

    Thank you LaurensM,

     

    I can't seem to get it to work. Could you look at the complete code below.

    Patch(BatchTrack, LookUp(BatchTrack, 'Batch ID'= BatchIDRePos.Text && 'Wafer ID'= WaferIDRePos.Text),
     {
     State: {Value: "TrackIn"},
     OpCode: Value(OpCodeRePos.Text),
     'Step Name': LookUp(Prod, OpCode01 = OpCodeRePos, Step.Text)
     }
    ))

    I set the variable Prod and it work correctly storing a text value.

    The Prod value is the same text as the list name which has been added as data to the app.

    OpCode01 is a number column in the list, OpCodeResPos is a number input in the app.

    Step is a column in the list referenced by the Prod variable.

     

    I can't see anything wrong with the code so I'm wondering if it's something to do with delegation.

     

    Thanks again.

     

    Rob

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard