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 / Gallery sort for 1 and...
Power Apps
Suggested Answer

Gallery sort for 1 and 10 not working

(1) ShareShare
ReportReport
Posted on by 134
Im having what I never thought would be an issue. My Gallery sorts on several search criteria which are input through variables. They are set with the blocks in the image.


The OnSelect of the Region is 
Set(
    varS4Region, Concat(
    RegionSearch.SelectedItems, Value, ", ")
)

The gallery sort is (sorry, here it comes. there might be a way to make it more efficient but this is what I know how to do)
SortByColumns(
    If(
//Look at "Redlist" of outdated items that havent been updated in 700+ days
        varredlist = true,
        Filter(
            colContacts,
    //Look for the date plus all subsearch items.
            And(
                (DateDiff(
                    DateValue('Last Contact'),
                    Today()
                ) >= 700),
    //Check if a subsearch item has a Match, if its Blank, move on to next subsearch item
                Or(varS1Company in Company || varS1Company = Blank()),
                Or(varS3City exactin Address || varS3City = Blank()),
        //Turn multichoice variable into string to look in text column for comparisons, turn text column into split characters
                Or(
                    varS4Region in Concat(
                        Region2, Value,
                        ", "
                    ) || IsBlank(varS4Region)
                ),
         //Compare individual items in multichoice with individual items in multichoice (repeated for each multichoice variable)
                Or(
                    Concat(
                        varS5County,
                        Value,
                        ", "
                    ) in Concat(
                        'Employer County',
                        Value,
                       ","
                    ) || IsBlank(varS5County)
                ),
                Or(
                    Concat(
                        varS6Education,
                        Value,
                        ", "
                    ) in Concat(
                        'Education Required',
                        Value,
                        ", "
                    ) || IsBlank(varS6Education)
                ),
                Or(
                    Concat(
                        varS7Offense,
                        Value,
                        ", "
                    ) in Concat(
                        'Offense Requirements ',
                        Value,
                        ", "
                    ) || IsBlank(varS7Offense)
                ),
                Or(
                    Concat(
                        varS8Business,
                        Value,
                        ", "
                    ) in Concat(
                        Option,
                        Value,
                        ", "
                    ) || IsBlank(varS8Business)
                ),
                Or(
                    Concat(
                        varS9Career,
                        Value,
                        ", "
                    ) in Concat(
                        'Career Cluster',
                        Value,
                        ", "
                    ) || IsBlank(varS9Career)
                )
            )
        ),
//Look at "Greenlist" of for items that have been created within the last 30 days
        vargreenlist = true,
        Filter(
            colContacts,
            And(
                DateDiff(
                    DateValue(Created),
                    Today()
                ) <= 30
            ),
            Or(varS1Company in Company || varS1Company = Blank()),
            Or(varS3City exactin Address || varS3City = Blank()),
            Or(
                    varS4Region in Concat(
                        Region2, Value,
                        ", "
                    ) || IsBlank(varS4Region)
                ),
            Or(
                Concat(
                    varS5County,
                    Value,
                    ", "
                ) in Concat(
                    'Employer County',
                    Value,
                    ", "
                ) || IsBlank(varS5County)
            ),
            Or(
                Concat(
                    varS6Education,
                    Value,
                    ", "
                ) in Concat(
                    'Education Required',
                    Value,
                    ", "
                ) || IsBlank(varS6Education)
            ),
            Or(
                Concat(
                    varS7Offense,
                    Value,
                    ", "
                ) in Concat(
                    'Offense Requirements ',
                    Value,
                    ", "
                ) || IsBlank(varS7Offense)
            ),
            Or(
                Concat(
                    varS8Business,
                    Value,
                    ", "
                ) in Concat(
                    Option,
                    Value,
                    ", "
                ) || IsBlank(varS8Business)
            ),
            Or(
                Concat(
                    varS9Career,
                    Value,
                    ", "
                ) in Concat(
                    'Career Cluster',
                    Value,
                    ", "
                ) || IsBlank(varS9Career)
            )
        ),
        Filter(
            colContacts,
            And(
                Or(varS1Company in Company || varS1Company = Blank()),
                Or(varS3City exactin Address || varS3City = Blank()),
                Or(
                    varS4Region in Concat(
                        Region2, Value,
                        ", "
                    ) || IsBlank(varS4Region)
                ),
                Or(
                    Concat(
                        varS5County,
                        Value,
                        ", "
                    ) in Concat(
                        'Employer County',
                        Value,
                        ", "
                    ) || IsBlank(varS5County)
                ),
                Or(
                    Concat(
                        varS6Education,
                        Value,
                        ", "
                    ) in Concat(
                        'Education Required',
                        Value,
                        ", "
                    ) || IsBlank(varS6Education)
                ),
                Or(
                    Concat(
                        varS7Offense,
                        Value,
                        ", "
                    ) in Concat(
                        'Offense Requirements ',
                        Value,
                        ", "
                    ) || IsBlank(varS7Offense)
                ),
                Or(
                    Concat(
                        varS8Business,
                        Value,
                        ", "
                    ) in Concat(
                        Option,
                        Value,
                        ", "
                    ) || IsBlank(varS8Business)
                ),
                Or(
                    Concat(
                        varS9Career,
                        Value,
                        ", "
                    ) in Concat(
                        'Career Cluster',
                        Value,
                        ", "
                    ) || IsBlank(varS9Career)
                )
            )
        )
    ),
    "Company",
    SortOrder.Ascending
)


Every search is working, except the search for Region 1. Region 10 works, but when searching Region 1, you still only get region 10 results. There is for sure qualifying data.
The things I've tried so far are:
-Making RegionSearch a single choice only
-Update the input for region 1 to 01
-Trim and TrimEnds on both the variable and the column

probably several other things I cant remember. no matter what, region 1 or 01 never shows up properly.
heres just one screenshot of proof that there are qualifying items

And evidence that the other regions search perfectly fine.



Any assistance is appreciated, thank you so much!
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,493 Super User 2025 Season 2 on at
    Hi
     
    Curiosity Question: why is everything OR'd together versus And'd together?
     
    So without try to diversify (yes I mean that literally) all your code, here is what I will say
     
    1. Concat is fine, BUT I do not see where you make sure that both Concats are in the same order.
     
    My Guess is you are using the value,value,value, because you don't want 1 to be seen as true, when someone selects 31 or 10 or 11.
     
    Add 4 labels please
     
    Label 1. Put the Concat of what they selected in the Regions (NOT the variable), just directly Concat the SelectedItems
    Label 2. Put the Variable of your concat for your Regions
    Label 3. Put the Concat of your Region2 field.
     
    This way we can visually verify IF the string you need to check are actually there. And it will help us verify if THAT is actually the issue.
     
    Please do that and if its obvious please mark my answer as the answer. If not paste them here and I can look deeper.
     
  • BHaapi Profile Picture
    134 on at
    @FLMike,
    they are And() at the beginning and Or() throughout because if they do not enter any data, the variable shows blank, which wasn't letting the gallery filter with the blanks on each one. I know there is a better way, but this was the first way i was able to get the sorting to work. 
     
    I'm not sure what happened overnight, but i just logged in to build the boxes (they all match!) and somehow the 01 search is now working. I didn't change any code at all, so IDK why, after 3 days of struggles, this finally worked.

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 765 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 272

Last 30 days Overall leaderboard