cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Resolver II
Resolver II

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
Super User
Super User

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
Resolver II
Resolver II

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,662)