cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Advocate III
Advocate III

Sort Gallery by multiple choice columns

I'm working on a nested gallery using SharePoint data. The data is sorted by Regional Office and it is working fine. The issue is that I need to sort by a second column (State). Both the Regional Office and the State are choice columns. 

 

Sorting / Grouping by Regional Office works fine:

SortByColumns(
    GroupBy(
        AddColumns(
            Filter(
                'Catalog',
                Year = "2021"
            ),
            "RO",
            'Regional Office'.Value
        ),
        "RO",
        "GrouppedROs"
    ),
    "RO",
    Ascending
)

 

When I try to add a second sorting parameter (State), it fails:

 

SortByColumns(
    GroupBy(
        AddColumns(
            Filter(
                'Catalog',
                Year = "2021"
            ),
            "RO",
            'Regional Office'.Value,
            "TheState",
            'State'.Value
        ),
        "RO",
        "GrouppedROs"
    ),
    "RO",
    Ascending,
    "TheState",
    Ascending
)

 

I get an error that says in part that "TheState" column doesn't exist:

 

Annotation 2021-09-03 111216.jpg

 

I have the feeling that all the issue is that I'm creating or placing TheState column in the wrong place. Any idea what am I doing wrong?

Thanks in advance.

 

2 REPLIES 2
Ashwin7104
Responsive Resident
Responsive Resident

Hey @emfuentes27 ,

 

Try the below code - I have used ShowColumns instead of Add Columns to ensure TheState exists.

GroupBy(
SortByColumns(
        ShowColumns(
            Filter(
                'Catalog',
                Year = "2021"
            ),
            "RO",
            "TheState"
    ),
    "RO",
    Ascending,
    "TheState",
    Ascending
),
        "RO",
        "GrouppedROs"
		)

emfuentes27
Advocate III
Advocate III

Thanks for the suggestion @Ashwin7104, but as far as I know I have to use AddColumns also, otherwise how would I define "RO" and the 'TheState". I use AddColumns to define Regional Office.value, as "RO", and "TheState" from State.value?

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,740)