cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cycle4passion
Helper II
Helper II

Filtering a Gallery/SubGallery

I am having trouble filtering a Gallery. This works as expected without search filtering. When searching by OwnerMD it also works correctly. When I search by 'Lastname', or 'LinkedExtender' I do not have any data.

ParentGallery.Items = 

 

GroupBy(
AddColumns(    
SortByColumns(
        Filter(
            CensusVU,
            (Active || User().Email = OwnerMD || IsExtender || IsAdmin) &&
            (TextSearch.Text in OwnerMD ||
            TextSearch.Text in LinkedExtender ||            
            TextSearch.Text in Lastname)
        ),
        "Hospital",
        Distinct(Hospitals, hospname)
    ),
    "Hospital1",
    Hospital
),
    "Hospital",
    "grpHosp"
)

 


GalleryChild.Items =

 

 

Sort(ThisItem.grpHosp, Room, Descending)

 

 

 Curiously, I happen to have header in the ParentGallery that indicates the correct number of items via the formula: 

 

 

ThisItem.Hospital & " (" & CountRows(ThisItem.grpHosp) & ")" 

 

 

 but no data shows?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @cycle4passion 

Please try this.  It obtains the first table by search, then filters it by your conditions.  I believe the search will work but I'm not sure about the Filter because I don't know where 3 of the 4 terms come from. User().Email=OwnerMD is pretty straighforward

 

With(
    {FilteredHospitals:
        Sort(
             Filter(
                    Search(
                            CensusVU, TextSearch.Text, "OwnerMD, "LinkedExtender","Lastname"
                       ),
                     OR(Active, User().Email = OwnerMD, IsExtender, IsAdmin
                     )
              ),
            "Hospital",
            SortOrder.Ascending
        )
    },
    GroupBy(
        FilteredHospitals,
        "Hospital",
        "grpHosp"
    )
)

 

  

View solution in original post

5 REPLIES 5
Drrickryp
Super User II
Super User II

Hi @cycle4passion 

Could you try the following and let me know if it works. 

 

 

With(
      {FilteredHospitals:
         Sort(
              Filter(
                CensusVU,
                  OR(Active,User().Email = OwnerMD ,
                     IsExtender,
                     IsAdmin
                   ) &&
                  OR(TextSearch.Text in OwnerMD,
                     TextSearch.Text in LinkedExtender,      
                     TextSearch.Text in Lastname
                  )
               ), 
              hospname, Ascending)
          )
            
       },
     GroupBy(
             filteredHospitals, "hospname","grpHosp"
     )
)

 

The Idea is to do the filtering and sorting in the With() function and then to Group the resulting table.  I have no idea if the filter actually works although you say it does.  Another way to do it is to create a collection using a sorted and filtered table and then use the collection for the GroupBy()

 

@Drrickryp Thank you for your time. Had to fix a couple minor things (caps, etc) to remove errors, and have this....

With(
    {FilteredHospitals:
        Sort(
            Filter(
                CensusVU,
                Or(
                    Active,User().Email = OwnerMD,
                    IsExtender,
                    IsAdmin
                ) &&
                Or(
                    TextSearch.Text in OwnerMD,
                    TextSearch.Text in LinkedExtender,      
                    TextSearch.Text in Lastname
                )
            ),
            "Hospital",
            SortOrder.Ascending
        )
    },
    GroupBy(
        FilteredHospitals,
        "Hospital",
        "grpHosp"
    )
)

but unfortunately, this fails on filtering of "Lastname" or "LinkedExtender" in the same way my original did.

Hi @cycle4passion 

Please try this.  It obtains the first table by search, then filters it by your conditions.  I believe the search will work but I'm not sure about the Filter because I don't know where 3 of the 4 terms come from. User().Email=OwnerMD is pretty straighforward

 

With(
    {FilteredHospitals:
        Sort(
             Filter(
                    Search(
                            CensusVU, TextSearch.Text, "OwnerMD, "LinkedExtender","Lastname"
                       ),
                     OR(Active, User().Email = OwnerMD, IsExtender, IsAdmin
                     )
              ),
            "Hospital",
            SortOrder.Ascending
        )
    },
    GroupBy(
        FilteredHospitals,
        "Hospital",
        "grpHosp"
    )
)

 

  

View solution in original post

This also gave me the same result (filtered on OwnerMD, but not on others). I simplified everything down to new gallery (filtered correctly), added child gallery into that and it worked fine. So I knew I had something off in my original. If you remember I had commented that I had a banner on the parent gallery and that showed the correct number of records, but no data below.

This is where my issues was, Because I had a nested gallery, I had previously set height of the child gallery based upon number of records for each group * height of each record. I had failed to update the filter there to match my filter for the gallery itself and that's why the data didn't show (via my approach, or yours x2).  

Thank you so much for your time again.

giphy.gif

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (81,794)