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 / How to replace a Share...
Power Apps
Answered

How to replace a SharePoint List name by a variable in formula

(0) ShareShare
ReportReport
Posted on by 16

Hi Power Apps team,

 

The pieces of code below are in french so the use of dot and semicolon are differents than english version

I have a problem with a Gallery and picture in attachement in a SharePoint list.

 

This code is running well to select Items for my Gallery

Filter(BoroA330;statut=position;snmoteur=SNmoteur)

 

For each Item in my Gallery, i want to display the last picture in attachment, no problem with this code:

Last(ThisItem.'{Attachments}').Value

 

But i have 6 differents SharePoint list, so i want to put the name of the lists in a variable like this:

Set(BDD;BoroA330)

Filter(BDD;statut=position;snmoteur=SNmoteur)

 

With this variable in my Gallery i can use all the fields of my List, it s running well:

ThisItem.element

 

But the code for the picture make an error. '{Attachments}' is not recognize

Last(ThisItem.'{Attachments}').Value

 

However in the OnSelect of my gallery i use a ClearCollect:

ClearCollect(colDefaut;ThisItem)

and i can display all the pictures in attachments in another screen in another Gallery using the property of an attachments box in a form named attPhotos :

attPhotos.Attachments

 

The solution i found is to use a Switch in my gallery to select the differents Lists:

Switch(type;
  "PW1500G";
  If(RadioChoixElement.Selected.element<>"All";
    Filter(BoroA220;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
    Filter(BoroA220;statut=position;snmoteur=SNmoteur)
);
"CFM56-5B";
  If(RadioChoixElement.Selected.element<>"All";
    Filter(BoroA320;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
    Filter(BoroA320;statut=position;snmoteur=SNmoteur)
);
"CF6-80E1";
  If(RadioChoixElement.Selected.element<>"All";
    Filter(BoroA330;statut=position;snmoteur=SNmoteur;element=RadioChoixElement.Selected.element);
    Filter(BoroA330;statut=position;snmoteur=SNmoteur)
);

 

This code is running well but it s heavy, ugly and it s a problem if i want to add or delete a List in the future because i have 6 or 7 switchs like this in my code. Maintenance and modification of the program are very complicated by this problem.

 

I tried many differents things but i can't understand why all fields ar recognized but not attachment.

 

Thank you for your patience and sorry for my english.

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    155,354 Most Valuable Professional on at

    Hi @LeVentriloque ,

    I will save you some time here - you cannot refer to data sources dynamically - you would have to hard-code it.

     

    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.

    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

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 834

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard