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 / 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:
I have the same question (0)
  • 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

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