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 / GroupBy function in co...
Power Apps
Answered

GroupBy function in collections

(1) ShareShare
ReportReport
Posted on by 93
Hello,
 
Im trying to use groupBy like this:
 
ClearCollect(groupOperaceFinal;GroupBy(colOperaceFinal; crf13_Operace; crf13_VNKN))
 
Obligate error is:
*text, number or logical value expected
*some arguments of groupby invalid
 
Expect that has something to do with question marks in my entry collection colOperaceFinal. Am I right and why is that? In the datasource for original collection these two are lookup columns. It is a joint table where there are records from tables containing the lists of "Operace" and "VNKN". In the joint table it looks like that:
 
ColumnLookupOperace                   ColumnLookupVNKN
Operace1                              VNKN1
Operace6                              VNKN5
Operace2                              VNKN1
Operace2                              VNKN7
Operace1                              VNKN5
Operace5                              VNKN5
etc.
Thank you
Categories:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,479 Super User 2025 Season 2 on at
    Hi
     
    if those are lookups you cannot use them to sort, you would need to target a property on the entity/table itself
  • Suggested answer
    Sam_Fawzi Profile Picture
    750 Super User 2025 Season 2 on at

    Let's break it down into a more conversational and easy-to-understand format.

     

     
     

    Creating a Grouped Collection in Power Apps

     

    If you're working with lookup columns in Power Apps, such as crf13_Operace and crf13_VNKN, and you want to create a new collection that groups data based on these columns, here’s how you can do it.

     

     

     
     
     

    Here’s What the Code Looks Like:

    ClearCollect(
        groupOperaceFinal,
        GroupBy(
            AddColumns(
                colOperaceFinal,
                "NewField1Name", crf13_Operace.Value,  // Get the value from crf13_Operace
                "NewField2Value", crf13_VNKN.Value      // Get the value from crf13_VNKN
            ),
            "NewField1Name",  // Group by the value from crf13_Operace
            "NewField2Value"  // Also group by the value from crf13_VNKN
        )
    )
    
     
     
    • ClearCollect(groupOperaceFinal, ...): This line is like saying, "Okay, let’s create a new collection called groupOperaceFinal and clear out anything that was there before."
    • AddColumns(...): Here, you're adding two new columns:
    • "NewField1Name": This will hold the actual values from your crf13_Operace lookup.
    • "NewField2Value": This will hold the values from your crf13_VNKN lookup.
     
    • GroupBy(...): Finally, you're grouping the data by the two new columns you just created. This means that all records with the same Operace and VNKN values will be grouped together.
     
     
     
     
     
     
     
     
     
     
     
     
     
     

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