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 / Compiling a collection...
Power Apps
Answered

Compiling a collection from a Sharepoint list

(0) ShareShare
ReportReport
Posted on by 100

Hi all,

 

I have an issue with one of my collection from Sharepoint.

 

Here is the architecture of my sharepoint List:

 

Document IDRole 1Role 2Role 3Role 4Role 5
ID001YesYesNo

No

Yes
ID002NoNoYesYesYes

 

I would like to make a collection from this with this architecture (List document IDs with Roles where Yes is selected):

 

Document IDRole
ID001Role 1
ID001Role 2
ID001Role 5
ID002Role 3
ID002Role 4
ID002Role 5

 

Do you think it is possible? How could I achieve this?

 

Thank you in advance for all the help you could give!

Categories:
I have the same question (0)
  • Verified answer
    v-yangar-msft Profile Picture
    Microsoft Employee on at

    Hi @cfoenki 

     

    Yes, its possible to achieve this based on your description.

    You can refer to the following steps as below:

    1.Here is the SharePoint list in my side:

    v-yangar-msft_0-1612422571112.png

     

    2.Add a button and set the OnSelect property of button to:

    ClearCollect(SampleCollect,SampleList)

     // SampleList is my sharepoint list, this formula aims to add a collection which use the sharepoint list value.

    3.Set the OnSelect property of button to:

    ClearCollect(SampleGroup,GroupBy(SampleCollect,"Title","Role1","Role2","Role3","Role4","Role5","Others"))

     //this formula aims to coalesce column which is hidden column in sharepoint list:

    v-yangar-msft_1-1612422571115.jpeg

    4.Set the OnSelect property of button to:

    ClearCollect(SampleCollection,DropColumns(SampleGroup,"Others"))

    // this formula aims to drop the other column

    5.Set the OnSelect property of button to:

    ClearCollect(SampleCollections,RenameColumns(SampleCollection,"Title","Document ID"))

    // this formula aims to Rename the column name

    v-yangar-msft_2-1612422571117.png

    6.Set the OnSelect property of button to:

    ClearCollect(SampleCollectionA,AddColumns(SampleCollections,"Role",""))

     // this formula aims to add a Role column

    7.Set the OnSelect property of button to:

    ForAll(SampleCollections,
    
    If(Role1=true,Patch(SampleCollectionA,Defaults(SampleCollectionA),{Role:"Role1",'Document ID':ThisRecord.'Document ID'}));
    
    If(Role2=true,Patch(SampleCollectionA,Defaults(SampleCollectionA),{Role:"Role2",'Document ID':ThisRecord.'Document ID'}));
    
    If(Role3=true,Patch(SampleCollectionA,Defaults(SampleCollectionA),{Role:"Role3",'Document ID':ThisRecord.'Document ID'}));
    
    If(Role4=true,Patch(SampleCollectionA,Defaults(SampleCollectionA),{Role:"Role4",'Document ID':ThisRecord.'Document ID'}));
    
    If(Role5=true,Patch(SampleCollectionA,Defaults(SampleCollectionA),{Role:"Role5",'Document ID':ThisRecord.'Document ID'}));)
    

    //this formula aims to add multi records which meet the condition Role=true and patch the right value.

    8.Set the OnSelect property of button to:

    ClearCollect(SampleCollectionB,DropColumns(SampleCollectionA,"Role1","Role2","Role3","Role4","Role5"))

    //this formula aims to drop the column role1~role5

    9.Set the OnSelect property of button to:

    ClearCollect(SampleCollectionC,RemoveIf(SampleCollectionB,Role=""))

    // this formula aims to remove two records which the value is blank.

    v-yangar-msft_3-1612422571119.png

     

     

    Hope it helps!

     

    Thanks,

    Arrow

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard