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 Switch function
Power Apps
Unanswered

Using Switch function

(0) ShareShare
ReportReport
Posted on by 834

hi all,

i am workin on an app that pulls user comapny from AD profile and based on that it provides the resource (SPO list) to read or write... works great. The problem or challenge is that i have to put in the switch in so many places. I was wondering if someone actually figured out how to have one place where i make the switch and that should feed all the other controls with the right values (compared to do the switch at every button/gallery,..etc..)

Categories:
I have the same question (0)
  • Adrian_Celis Profile Picture
    1,652 Moderator on at

    Hi @Sifu 

    Did you try to use global variables? You can use switch on the OnStart property of the app and then assign a variable to that. Then use that variable on your controls.

  • Sifu Profile Picture
    834 on at

    I had that idea but does not look like that gallery or patch can use a variable for source... 

  • Adrian_Celis Profile Picture
    1,652 Moderator on at

    Hi @Sifu 

    You're right unfortunately you can't assign a variable for a data source. It may be more convenient if you have all of your SPO lists combined in one list, then have a column to distinguish between them. So that in your app you can filter by that column based on your condition.

  • Sifu Profile Picture
    834 on at

    I dont think this can work. For the app, the source name in the SPO List would be just text... Can u show me how u mean it? 

  • Adrian_Celis Profile Picture
    1,652 Moderator on at

    Ok first,

    1. How many SPO lists do you have (that you are including in your switch function)?

    2. Does the lists have different columns (column names, etc) from each other?

     

  • Sifu Profile Picture
    834 on at

    for example i have a gallery that should read from the list "X" if user profile company name = "A", or from list "y" if company name is "B"... I assume you want to crate a list where you include these but from what i tested the values in the "mapping table" would be just text

  • Adrian_Celis Profile Picture
    1,652 Moderator on at

    Okay thanks for clarifying. No, I meant combine list X and list Y into one list (lets call it list XY). Then out of that combined list (list XY), just add a column (Let's call it 'ProfileCompanyName') indicating what profile company name it is. That way you can use filter in your galleries. For example, you can use this in the Items property of your gallery:

    Filter('list XY',ProfileCompanyName="A")

    We can replace "A" with a variable.

     

    That way, you don't need to create a Switch function with multiple arguments

     

     

     

  • Sifu Profile Picture
    834 on at

    ok i see but not good for my case... i need to use separated lists for security reasons, different access/permissions since different company and users

  • Adrian_Celis Profile Picture
    1,652 Moderator on at

    I see. You could set item-level permissions (certain groups can only see certain rows) in your SP list, and it won't be different from having separate lists inside one tenant with different permissions per list, but that would probably need some more work if you would modify it now. But it can be worth considering for future projects.

  • Sifu Profile Picture
    834 on at

    yes, surely something to consider but the permission might be harder to maintain if you add groups later and similar... but see your angle... for now I stay with switch.

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard