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 / Filter gallery using m...
Power Apps
Answered

Filter gallery using multiple switch case and conditions

(0) ShareShare
ReportReport
Posted on by 31

Hi, 

I need help to create filter query for below scenario.

I have master SP list (Master List {Title, SayYES, Main Type (Choice), Scenario (Choice), Change Type (Choice)}) and

child list (Activity list {Activity, Sort Order, Dry, chemical, Gas, Existing, New, Change Condition, Takeover, Owner Change, Name Change, Class change, Game change}).  both lists connected with column ID - MID

Master list choice column items will be the child list (Number Column) fields.  I need to filter the child list gallery (Activity list) based on master record item and those are 1's in child list columns. Please help with the filter query for activity list gallery.

 

Nazia786_0-1713258080149.png

All the highlighted column names as Number Type columns with 1 ,0 as values

Nazia786_1-1713258125054.png

 

Nazia786_2-1713258184200.png

On master gallery selected:

Set(VarcolName,Upper(LookUp([@'Master List'], MainType = ThisItem.'Main Type').MainType)),
ClearCollect( colData, Filter([@'Activity list '], MID=ThisItem.ID)),

 

Items filter for Activity list gallery

SortByColumns(
Switch (VarcolName,"GAS",
   Filter (Coldata, GAS = 1),
  "DRY", Filter (Coldata, DRY = 1),
  "TANKER", Filter (Coldata, TANKER = 1)
), "Sort Order" ,SortOrder.Ascending)

 

I need to add one more switch case to Filter Scenario and Change type. to show the activities names in gallery those columns have "1's"

How can I do. Kindly advise. Thank you.

 

 

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

    Hi @Nazia786 ,

     

    I don't recommend you do this because the branches will reach 48. (3*4*4)

    Please try to optimize the structure of your second table.

    Sample:

    vxiaochenmsft_0-1713322368384.png

    Then try these formulas

     

    Set(VarcolName,Upper(LookUp([@'Master List'], MainType = ThisItem.'Main Type').MainType));
    ClearCollect( colData, Filter([@'Activity list '], MID=ThisItem.ID));
    Set(VarcolName2,Upper(LookUp([@'Master List'], Scenario= ThisItem.Scenario).Scenario));
    Set(VarcolName3,Upper(LookUp([@'Master List'], 'Change Type'= ThisItem.'Change Type').'Change Type'));
    
    
    SortByColumns(Filter (Coldata, VarcolName in MainType && VarcolName2 in Scenario && VarcolName3 in 'Change Type' ), "Sort Order" ,SortOrder.Ascending)

     

     

    Best Regards,

    Wearsky

  • Nazia786 Profile Picture
    31 on at

    Hi@v-xiaochen-msft 

    Thank you for your reply.. 

    Share point lists already exists with 2k records.  it's difficult to change the structure of table now.

    Main type and Scenario are single select choice columns in master list. 

    if the record selected in master gallery Main type = "DRY"  , Scenario = "New"

    I need to filter the red highlighted activities.   

    Nazia786_0-1713324064970.png

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Nazia786 ,

     

    I'm afraid this is difficult to achieve due to limitations of your table structure.

     

    Best Regards,

    Wearsky

  • Nazia786 Profile Picture
    31 on at

    Hi @v-xiaochen-msft 
    Please kindly advise, if I change the table structure. then I need to make the Main type, Scenario, Change type columns to Multiselect Choice columns.  then how can I change the below query to filter my gallery activity names. 

     

    SortByColumns(Filter (Coldata, VarcolName in MainType && VarcolName2 in Scenario && VarcolName3 in 'Change Type' ), "Sort Order" ,SortOrder.Ascending)

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Nazia786 ,

     

    I think it should be 

    SortByColumns(Filter (Coldata, VarcolName in MainType.Value || VarcolName2 in Scenario.Value || VarcolName3 in 'Change Type'.Value ), "Sort Order" ,SortOrder.Ascending)

     

    Best Regards,

    Wearsky

  • Nazia786 Profile Picture
    31 on at

    Hi @v-xiaochen-msft  

    your proposed solution is working for me as of now.  Thank you very much for that.

    SortByColumns(Filter (Coldata, VarcolName in MainType.Value || VarcolName2 in Scenario.Value || VarcolName3 in 'Change Type'.Value ), "Sort Order" ,SortOrder.Ascending)

     

    Please advise on my 2 questions, 

    1.  Maintype, Scenario, Changetype are multi select choice columns. will it work out with large data filtering? delegation issue might occur right?

     

    2. if VarcolName3 is not just one value. if we have, multiple values in this variable like table. then how to filter 

    one multiselect column IN another multiselect column? 

     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 414

#2
Valantis Profile Picture

Valantis 408

#3
timl Profile Picture

timl 339 Super User 2026 Season 1

Last 30 days Overall leaderboard