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 by many...
Power Apps
Answered

Filter Gallery by many-to-many multi-select combobox

(0) ShareShare
ReportReport
Posted on by 35

Hi all,

 

Currently converting a Canvas App to sit on Dataverse for Teams (previously sat on SharePoint Lists). Having established all relationships, I am struggling to replicate a particular set of filter criteria on a couple of galleries. One such example is below.

 

I have three relevant tables: 'Organisations', 'People', and 'Activity'

 

The gallery to display 'Activity' records has a series of filters linked to multi-select combo boxes on the same screen. Most logical tests are fairly straightforward, however a few are filtering the 'Activity' gallery based on many-to-many relationships between the 'Activity' table and the 'Organisations' and 'People' tables respectively.

 

A slightly anonymised copy of the Items property code is shown below. Also, here are the many-to-many relationship names within Dataverse as used in the formula - all are OOB many-to-many: 

 

  • 'cr02d_Act_rel_Peo_Staffother' - staff attendees, related to records in the People table
  • 'cr02d_Act_rel_Peo_MainOrgAtt' - primary activity attendees, related to records in the People table
  • 'cr02d_Act_rel_Peo_OtherOrgAtt' - alternative activity attendees, related to records in the People table
  • 'cr02d_Act_rel_Org_OtherOrgs' - activity attendee organisations, related to records in the Organisations table

 

 

Filter(
//// sort by date, ordered ascending or descending as selected
 Sort(
 Activities,
 Date,
 If(
 searchDateOrder = SortOrder.Ascending,
 SortOrder.Ascending,
 SortOrder.Descending
 )
 ),
//// filter by date
 Date >= dbox_StartDate_SearchAct.SelectedDate,
 Date <= dbox_EndDate_SearchAct.SelectedDate,
//// filter contact reason
 IsBlank(cbox_MtgReason_SearchAct.SelectedItems) || IsEmpty(cbox_MtgReason_SearchAct.SelectedItems) || Reason in cbox_MtgReason_SearchAct.SelectedItems.Value,
//// filter meeting format
 IsBlank(cbox_MtgFormat_SearchAct.SelectedItems) || IsEmpty(cbox_MtgFormat_SearchAct.SelectedItems) || Formats in cbox_MtgFormat_SearchAct.SelectedItems.Value,
//// filter teams
 IsBlank(cbox_Team_SearchAct.SelectedItems) || IsEmpty(cbox_Team_SearchAct.SelectedItems) || Teamlead.teams in cbox_Team_SearchAct.SelectedItems.Value,
//// filter staff - need to check 'lead' and 'other' attendees
 IsBlank(cbox_TeamStaff_SearchAct.SelectedItems) || IsEmpty(cbox_TeamStaff_SearchAct.SelectedItems) || Teamlead.FullName in cbox_TeamStaff_SearchAct.SelectedItems.FullName ||
//// this construction is required since there can be more than one person selected in filter, and more than one person related as other staff.
 true in ForAll(
 ThisRecord.'cr02d_Act_rel_Peo_Staffother',
 ThisRecord in cbox_TeamStaff_SearchAct.SelectedItems
 ),
//// filter other org staff 
 IsBlank(cbox_OrgStaff_SearchAct.SelectedItems) || IsEmpty(cbox_OrgStaff_SearchAct.SelectedItems) ||
//// need to check main org attendees using same construction as above
 true in ForAll(
 ThisRecord.'cr02d_Act_rel_Peo_MainOrgAtt',
 ThisRecord.FullName in cbox_OrgStaff_SearchAct.SelectedItems
 ) ||
//// need to check other org attendees using same construction as above
 true in ForAll(
 ThisRecord.'cr02d_Act_rel_Peo_OtherOrgAtt',
 ThisRecord.FullName in cbox_OrgStaff_SearchAct.SelectedItems
 ),
//// filter main and other orgs
 IsBlank(cbox_Orgs_SearchAct.SelectedItems) || IsEmpty(cbox_Orgs_SearchAct.SelectedItems) || MainOrg.OrgName in cbox_Orgs_SearchAct.SelectedItems.OrgName ||
//// need to check each value in OtherOrgs field
 true in ForAll(
 ThisRecord.'cr02d_Act_rel_Org_OtherOrgs',
 ThisRecord.OrgName in cbox_Orgs_SearchAct.SelectedItems.OrgName
 )
)

 

 

The 'true in ForAll()' elements do work, however warn about referencing the many-to-many relationship and potential performance impacts. The warning is valid - these filters are extraordinarily slow with c.500 records in each table.

 

Is there a more efficient way to handle this type of gallery filtering against a related record that can handle multiple selections, or do i need to go back to the drawing board on this app?

 

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

    Hi @DamonUK ,

     

    If you create collections OnChange of all the three Combo boxes, then filter columns in respective collection, would it help enhance App performance? colTeamStaff, colOrgStaff and colOrg are created OnChange:

    Filter(
    //// sort by date, ordered ascending or descending as selected
     Sort(
     Activities,
     Date,
     If(
     searchDateOrder = SortOrder.Ascending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
     ),
    //// filter by date
     Date >= dbox_StartDate_SearchAct.SelectedDate,
     Date <= dbox_EndDate_SearchAct.SelectedDate,
    //// filter contact reason
     IsBlank(cbox_MtgReason_SearchAct.SelectedItems) || IsEmpty(cbox_MtgReason_SearchAct.SelectedItems) || Reason in cbox_MtgReason_SearchAct.SelectedItems.Value,
    //// filter meeting format
     IsBlank(cbox_MtgFormat_SearchAct.SelectedItems) || IsEmpty(cbox_MtgFormat_SearchAct.SelectedItems) || Formats in cbox_MtgFormat_SearchAct.SelectedItems.Value,
    //// filter teams
     IsBlank(cbox_Team_SearchAct.SelectedItems) || IsEmpty(cbox_Team_SearchAct.SelectedItems) || Teamlead.teams in cbox_Team_SearchAct.SelectedItems.Value,
    //// filter staff - need to check 'lead' and 'other' attendees
     IsBlank(cbox_TeamStaff_SearchAct.SelectedItems) || IsEmpty(cbox_TeamStaff_SearchAct.SelectedItems) || Teamlead.FullName in colTeamStaff.FullName ||
    //// this construction is required since there can be more than one person selected in filter, and more than one person related as other staff.
     ThisRecord.'cr02d_Act_rel_Peo_Staffother'.FullName in colTeamStaff.FullName
     ),
    //// filter other org staff 
     IsBlank(cbox_OrgStaff_SearchAct.SelectedItems) || IsEmpty(cbox_OrgStaff_SearchAct.SelectedItems) ||
    //// need to check main org attendees using same construction as above
     ThisRecord.'cr02d_Act_rel_Peo_MainOrgAtt'.FullName in colOrgStaff.FullName
     ) ||
    //// need to check other org attendees using same construction as above
     ThisRecord.'cr02d_Act_rel_Peo_OtherOrgAtt'.FullName in colOrgStaff.FullName
     ),
    //// filter main and other orgs
     IsBlank(cbox_Orgs_SearchAct.SelectedItems) || IsEmpty(cbox_Orgs_SearchAct.SelectedItems) || MainOrg.OrgName in colOrgs.OrgName ||
    //// need to check each value in OtherOrgs field
     ThisRecord.'cr02d_Act_rel_Org_OtherOrgs'.OrgName in colOrgs.OrgName
     )
    )

     

    Best regards,

  • DamonJay Profile Picture
    35 on at

    Hi @v-jefferni 

     

    Thanks for responding. I've incorporated your suggestions, however am receiving an error against each revised line saying "Invalid Argument Type. Cannot use table value in this context."

     

    Screenshot 2023-07-19 125014.png

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @DamonUK ,

     

    I know where the problem is now. However, I have to say that I don't think there could be a more efficient way to go through it. The formula needs to process fields by fields of each item, while each field of a column with many to many relationship holds a table that you need to compare with another table, this will spend much more time than comparing with a text or number column.

     

    Best regards,

  • DamonJay Profile Picture
    35 on at

    Thanks @v-jefferni 

     

    In discussions with an experienced colleague we were reaching the same conclusion. 

     

    I will instead look at more efficient ways of displaying the required user outputs with some pre-filtering of the raw table data or perhaps via Dataverse views. Back to the user research it is 😁

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard