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 / Collecting different c...
Power Apps
Unanswered

Collecting different collections based on variable

(0) ShareShare
ReportReport
Posted on by 64

Hi everybody, 

I have to modify a PowerApp and need some help. We have a SharePoint list with >10k items. ClearCollect is working fine. Now there is another departments SharePoint list we want to use, depending on which department the user is working for. We check on AppStart the department and using var_department.

 

There are three options: 

1. var_departement = "dept1"

2. var_departement = "dept2"

3. var_departement = "dept1 & dept2"

 

Option 3 should show a popup, where the user needs to select the departements list that should be collected. 

 

To collect the SharePoint list of Departement 1 or 2, I tried this (without any collected items): 

 

 

If(var_dept = "dept1"; (Concurrent(
 ClearCollect(
 col_dept1_1;
 Filter(
 SPO_list_dept1;
 Or(
 StartsWith(
 Batchloading;
 "A"
 );
 StartsWith(
 Batchloading;
 "B"
 )
 )
 )
 );
 ClearCollect(
 col_dept1_2;
 Filter(
 SPO_list_dept1;
 Or(
 StartsWith(
 Batchloading;
 "C"
 );
 StartsWith(
 Batchloading;
 "D"
 )
 )
 )
 )
)); 
false);;
If(var_dept = "dept2"; (Concurrent(
 ClearCollect(
 col_dept1_1;
 Filter(
 SPO_list_dept2;
 Or(
 StartsWith(
 Batchloading;
 "A"
 );
 StartsWith(
 Batchloading;
 "B"
 )
 )
 )
 );
 ClearCollect(
 col_dept1_2;
 Filter(
 SPO_list_dept2;
 Or(
 StartsWith(
 Batchloading;
 "C"
 );
 StartsWith(
 Batchloading;
 "D"
 )
 )
 )
 )
)); 
false);;
Concurrent(
 ClearCollect(
 col_dept;
 col_dept1_1;
 col_dept1_2))

 

 

Any idea how I use the if-statement for var_dept in the beginning the right way? 

 

Thanks! 

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Frank89

    I have not accounted for all the possibilities but this gives a framework for you to help clarify the options.  You can add the options to the with statement and then use the Switch() to indicate which option is valid.

     

     

    With({option1:Filter(
     SPO_list_dept1; Or(
     StartsWith(
     Batchloading; "A"
     ); StartsWith( 
     Batchloading; "B"
     )
     )
     );
     option2:Filter(
     SPO_list_dept1; Or(
     StartsWith(
     Batchloading; "C"
     ); StartsWith( 
     Batchloading; "D"
     )
     )
     )
     };
     Switch(
     var_dept,"dept1"; option1; 
     "dept2"; option2
     )
    )

     

     

     

     

     

     

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard