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 / Dynamic gallery item f...
Power Apps
Answered

Dynamic gallery item from string

(0) ShareShare
ReportReport
Posted on by 157

Hello, 

 

I am using the following formula to set a variable that is used in the item property of a gallery, however the following code requires me to manually add a case for a new client

 

Switch(
 ClientDropDown.SelectedText.Value;

 Text("CLIENT_1");
 Set(varClient;CLIENT_1);
 
 Text("CLIENT_2");
 Set(varClient;CLIENT_2)

 Text("CLIENT_N");
 Set(varClient;CLIENT_N)

 )

 

 

I have been trying to set the variable directly from the selected value (therefore avoiding having to make manual changes if a new client gets added)

 

for example: 

 

Set(varClient;ClientDropDown.SelectedText.Value)

 

 

This will set the variable, however it is  text and the variable can then not be used as the item source. 

 

Can anyone suggest a way I can get the functionality of the above switch code but without having to hardcode the clients? 

 

Thanks in advance

Categories:
  • WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Hi @td1979 ,

    I am not entirely clear why

    Set(
     varClient;
     ClientDropDown.Selected.Value
    )

    is not doing what you need (the text would be the client's name I suspect) - what is it exactly you are trying to set ?

  • td1979 Profile Picture
    157 on at

    thanks for your help/time

     

    I have a collection of client names that correspond to data connections in the app. 

     

    i.e.  

     

    Set(
     varMyDataConnectionName;
     ClientNameThatCorrespondsToACollection.Selected.Value
    )

     

     

    dependant dropdowns and galleries work fine if I use switch and hardcode

     

  • Verified answer
    WarrenBelz Profile Picture
    156,570 Most Valuable Professional on at

    Hi @td1979 ,

    Unfortunately, you cannot refer to a Variable/Collection name with another Variable (without hard-coding)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard