web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create collections fro...
Power Apps
Unanswered

Create collections from SharePoint lists, with lookup columns

(0) ShareShare
ReportReport
Posted on by 34

Hi everyone,

 

In PowerApps I have two SharePoint lists as source (list "Request" and list "Assess"). These lists have common columns ("Contractor" and "Country"), of type lookup, that have as source a third list ("Assets" list). I need to create a collection to combine these two lists ("Request" and "Assess") into one table.

 

I was able to create the collection "SafetyAlertList", which combines these two lists "Request" and "Assess". However, this collection does not show values for the lookup type columns ("Contractor" and "Country").

AndreiaSola_1-1687273315514.png

 

Note: The "Country" and "Country2" columns should be only one. When the lists were created in SharePoint this was the initial name given to these columns and PowerApps does not recognize the current name.

 

Current formula:

ClearCollect(SafetyAlertList,AddColumns(ShowColumns(Filter('Request',Status = "Pending"),"Contractor","Country2"),"Status","Pending"));
Collect(SafetyAlertList,AddColumns(ShowColumns(Filter('Assess',Status = "Approve"),"Contractor","Country"),"Status","Approve"));

 

I've searched in several forums, watched several videos, and I actually found some similar things. However, I could not find any solution that solves this issue.

 

Has anyone had the same problem and managed to solve it? Can you help me, please?

 

Kind Regards.

Categories:
I have the same question (0)
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @AndreiaSola 

     

    You can either:

    ClearCollect(SafetyAlertList,RenameColumns(AddColumns(ShowColumns(Filter('Request',Status = "Pending"),"Contractor","Country2"),"Status","Pending"),"Country2","Country"));
    Collect(SafetyAlertList,AddColumns(ShowColumns(Filter('Assess',Status = "Approve"),"Contractor","Country"),"Status","Approve"));

     

    Or this:

    With(
     {
     _Pending: RenameColumns(AddColumns(ShowColumns(Filter('Request',Status = "Pending"),"Contractor","Country2"),"Status","Pending"),"Country2","Country"),
     _Approve: AddColumns(ShowColumns(Filter('Assess',Status = "Approve"),"Contractor","Country"),"Status","Approve")
     },
     ClearCollect(SafetyAlertList,
     Ungroup(
     Table(
     { varTable: _Pending},
     { varTable: _Approve}
     )
     ,"varTable"
     )
     )
    )

     

  • HectorOlivos Profile Picture
    411 on at

    It´s not recommended to work with LookUp columns, @WarrenBelz explains: "Lookup fields add considerable and completely unnecessary complication to both querying and writing data in Power Apps and are not Delegable on several levels."

     

    For more information: https://www.practicalpowerapps.com/data/constructing-your-first-power-app-before-you-start/

  • apsola Profile Picture
    34 on at

    Hi @cha_cha , thanks for your reply. I created a new collection "SafetyAlertList5" to test it, and your suggestion solves the column rename issue  👍 But the problem of lookup columns remains.

     

    AndreiaSola_0-1687276362945.png

     

     

    Let's see if we can find a solution.

    Thank you.

  • apsola Profile Picture
    34 on at

    Hi @HectorOlivos ! I appreciate your feedback. I still need these lookup columns in the SharePoint lists, as it may be necessary to submit a new item directly in SharePoint, without using PowerApps.

    If you have any idea how I can resolve this issue in the collection, I'd be very grateful.

     

    Thank you.

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @AndreiaSola 

     

    Try this:

    With(
     {
     _Pending: RenameColumns(
     DropColumns(
     AddColumns(
     ShowColumns(
     Filter(Request,Status = "Pending"),"Contractor","Country2")
     ,"Status","Pending"
     ,"Country",Country2.Value
     ,"ContractorValue",Contractor.Value
     )
     ,"Country2","Contractor"
     ),"ContractorValue","Contractor"
     )
     ,
     _Approve: RenameColumns(
     DropColumns(
     AddColumns(
     ShowColumns(Filter(Assess,Status = "Approve"),"Contractor","Country")
     ,"Status","Approve"
     ,"CountryValue",Country.Value
     ,"ContractorValue",Contractor.Value
     )
     ,"Country","Contractor"
     )
     ,"CountryValue","Country"
     ,"ContractorValue","Contractor"
     )
     },
     ClearCollect(SafetyAlertList2,
     Ungroup(
     Table(
     { varTable: _Pending},
     { varTable: _Approve}
     )
     ,"varTable"
     )
     )
    )
  • cha_cha Profile Picture
    4,932 Moderator on at

    I think you've done good thinking when setting the status to a Text Column instead of a Choice column. It made it easy for you to delegate the Filter job to SharePoint.

  • apsola Profile Picture
    34 on at

    Hi @cha_cha , thanks again, for your reply.

     

    The result is the same, no values in the lookup columns...

    Obs: I change the name of the collection "SafetyAlertList2" from your formula, to "SafetyAlertList6".

     

    AndreiaSola_0-1687279029529.png

     

     

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @AndreiaSola 

     

    I tried simulating your case in my environment and the code should work. Would you mind testing on a new power app and see if it works with small sets of data?

     

    This is a sample code where the first batch, I tried to retrieve the value from the Choice column named "ABC".

    cha_cha_0-1687339717376.png

     

    I have managed to display the data:

    cha_cha_1-1687339741415.png

    And try to see if these columns has value

    cha_cha_2-1687339771945.png

     

    Once clicked, it should show like this: 

    cha_cha_3-1687339789290.png

     

    Also, please test some of these:

    1. Re add the data source

    2. Add a new choice column that you can retrieve - maybe the current choice column have undergone some changes in structure like from Choice to Text or vise versa.

     

  • apsola Profile Picture
    34 on at

    Hello @cha_cha , thanks for your availability!

     

    I created a new app and added the formula according to your example:

    AndreiaSola_6-1687432363117.png

     

    Collection "TESTCOLL" result:

    AndreiaSola_7-1687432759818.png

     

    Obs.: Actually the "Collect" function is not needed in this case, because it's adding values that are already in "ClearCollect".

     

    When I click on an item from "Country" or "CountryValue", it shows like this:

    AndreiaSola_2-1687431288848.png

     

    This is the same result that I got with my other app.

    In the collections, the lookup columns appeared without values in the first view, and only by clicking on each grid icon, I can see the values in the second "layer".

     

    This makes that in a gallery, for example, the values of these columns don't show up. It gives an error in the formula (I've tried "ThisItem.Country.Value" and "ThisItem.Country", in the text label, and the result was the same):

     

    AndreiaSola_5-1687432185956.png

     

    I actually need the results like it shows in your "ABCVal" column, but it's not working for some reason that I don't know. Is it because the columns in the sharepoint lists are of type lookup and multiple selections?

     

    Kind Regards.

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @AndreiaSola 

     

    I just found a weird workaround.

     

    So got into wondering why it would not work, so what I did was below. I just did a retrieval of data using the normal way then after that hiding that part and doing a ClearCollect again as above. And so far it worked.

     

    (1) Add a gallery on one of the screens - this will be hidden screen, no need to access

    (2) Use the SP List as the data source

    (3) In the gallery, add a label that will call out the Multiselect LookUp Column.

     

    cha_cha_0-1687441502723.png

     

    By the way, since you have multiselect, you might need to use First(Country).Value instead of just Country.Value in your query.

     

    Please do some test first. and let me if it worked for you as well.

    cha_cha_1-1687441684177.pngcha_cha_2-1687441703484.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard