Skip to main content

Notifications

Community site session details

Community site session details

Session Id : jdcfzasOaD54BxZer1YIdR
Power Apps - Building Power Apps
Answered

PowerApps Filter - Table name as a variable

Like (0) ShareShare
ReportReport
Posted on 20 Oct 2020 17:15:16 by 26

My PowerApp application decides the Share point list to filter based on user details. For example, the Share Point list would change based on the region the user belongs to.

Share Point List:
SalesTableEU
SalesTableUSA

The mapping of User and the Sharepoint list to use is in another table named UserSettings.

First, i did a look up on UserSetting list, returned the SPListName (TableName) based on the user. This saved in a variable named SelectedDS (app, onStart) by

 

 

Set(SelectedDS, LookUp(UserSPLMapping, Title = User().Email, SPListName))

 

 

How should i pass the table name to the filter function (first landing page) based by this variable name - SelectedDS.

 

 

SortByColumns(Filter(SelectedDS, StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

 

I do not get the gallery populated when i use this variable, however when i hard code the table name, the gallery is populated.

Can you help me where i'm wrong and provide me a solution.

  • Sriram6000 Profile Picture
    26 on 21 Oct 2020 at 16:04:41
    Re: PowerApps Filter - Table name as a variable

    Thank you @RandyHayes. this helped

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 20 Oct 2020 at 17:28:12
    Re: PowerApps Filter - Table name as a variable

    @SS13 

    You cannot refer to datasources indirectly like that.  You need to provide the actual name.

    You can change your items to various datasources based on a condition.

    ex. 

    Switch(condition,
     "condition1", Filter(Table1, criteria),
     "condition2", Filter(Table2, criteria),
     ...etc...
    )

    But this is VERY risky to do in PowerApps unless the sources are EXACTLY the same and you have no plans to use any Forms in your app.

     

    Consider putting the Galleries, Forms and anything else you need in the app for all of your datasources and then just hide and display the appropriate screens or controls based on the region the user is in.

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    on 20 Oct 2020 at 17:24:19
    Re: PowerApps Filter - Table name as a variable

    Don't believe you can do what you're trying to do.  Set up multiple galleries and then show/hide them based on the value of SelectedDS.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started