Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

How to groupby choice column

(0) ShareShare
ReportReport
Posted on by 242

Hi Everyone 

Can someone please suggest me how to use GroupBy function with choice column. i have tried all they but nothing worked.

GroupBy(AddColumns('Abcr Tracker', "ChoiceText", Unit.Value), "ChoiceText",    "GroupedData")
attached is the screenshot.

 

 

Categories:
  • Paramesh Ulthi Profile Picture
    15 on at
    How to groupby choice column
    In PowerApps, grouping data based on a **Choice** column from a SharePoint list can be tricky because PowerApps treats **Choice** columns as records rather than simple text values. However, you can work around this by converting the **Choice** values into text and then using the `GroupBy` function.
    Here's a step-by-step approach to group data by a SharePoint **Choice** column in PowerApps:
    ### Scenario:
    You have a SharePoint list with a **Choice** column, and you want to group items based on this column.
    ### Steps:
    1. **Retrieve the Data:**
       First, retrieve your SharePoint list data using the `Choices` function. Assuming your SharePoint list is called `MyList` and the **Choice** column is `Status`:
       ```PowerApps
       ClearCollect(MyCollection, MyList)
       ```
    2. **Convert the Choice Column to Text:**
       Since the **Choice** column is treated as a record, you need to access the actual text value. You can use `ThisRecord.Status.Value` (replace `Status` with your column name).
       ```PowerApps
       AddColumns(MyCollection, "StatusText", Status.Value)
       ```
    3. **Use the GroupBy Function:**
       Now that you have converted the **Choice** column to text (`StatusText`), you can group the data based on this new column.
       ```PowerApps
       GroupBy(AddColumns(MyCollection, "StatusText", Status.Value), "StatusText", "GroupedItems")
       ```
    4. **Display the Grouped Data:**
       You can bind this grouped collection to a gallery or any control where you need to display grouped data. For instance:
       - Use a gallery to display the unique **Status** values (group headers).
       - Inside that gallery, you can use another gallery to display the items under each group.
    ### Full Example:
    Assume your SharePoint list is named `MyList`, and you want to group items based on the **Status** choice column.
    ```PowerApps
    ClearCollect(MyCollection, MyList);
    ClearCollect(
        GroupedCollection,
        GroupBy(
            AddColumns(MyCollection, "StatusText", Status.Value),
            "StatusText",
            "GroupedItems"
        )
    );
    ```
    - `MyCollection`: Holds the data from the SharePoint list.
    - `GroupedCollection`: Contains the grouped data where each record has a `StatusText` (group name) and `GroupedItems` (items in that group).
    Now, bind `GroupedCollection` to a gallery control, and within that gallery, you can display the grouped data.
    ---
    Let me know if you need help with displaying or manipulating the grouped data!
  • aayaanmayank Profile Picture
    242 on at
    Re: How to groupby choice column
    thanks It worked
  • Verified answer
    CarlosFigueira Profile Picture
    on at
    Re: How to groupby choice column

    @aayaanmayank is your Power Apps version 3.24042 or later? If so, there was a change in the syntax of those functions (see blog post and release notes), so it should be written as

    GroupBy(
     AddColumns('Abcr Tracker', ChoiceText, Unit.Value),
     ChoiceText,
     GroupedData)

    Hope this helps!

  • aayaanmayank Profile Picture
    242 on at
    Re: How to groupby choice column

    there is no difference in both the formulas but i have tried and still getting the same error 

  • mmbr1606 Profile Picture
    12,108 Super User 2025 Season 1 on at
    Re: How to groupby choice column

    hey @aayaanmayank 

     

    can you try this please:

    GroupBy(
     AddColumns(
     'Investment request Tracker',
     "ChoiceText", Unit.Value
     ),
     "ChoiceText",
     "GroupedData"
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,631 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,991 Most Valuable Professional

Leaderboard