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 / Collection with GroupB...
Power Apps
Suggested Answer

Collection with GroupBy, AddColumn and LookUp Columns

(1) ShareShare
ReportReport
Posted on by 93
Hello
 
how can I use GroupBy with lookup columns in the table please?
 
I have a joint table OperaceVNKN with columns Operace and VNKN (Operace is lookup column where it takes column Nazev from table Operace, VNKN is lookup column Seznam in table VNKN)
 
Tried this:
 
ClearCollect(
groupOpe;
AddColumns(
GroupBy(
OperaceVNKN;
Operace;
VNKN
);
skupOperace;
CountIf(OperaceVNKN;true)
)
)
 
Can anyone see a problem? Thanks
Categories:
I have the same question (0)
  • Suggested answer
    Jon Unzueta Profile Picture
    1,827 Super User 2025 Season 2 on at
     

    Thanks for sharing your formula and context! You're close, but there are a few things to clarify when using GroupBy with lookup columns in Power Apps.

     Problem Breakdown

    You're trying to group a collection (OperaceVNKN) by two lookup columns: Operace and VNKN. However, GroupBy in Power Apps works best with text or primitive values, not complex records like lookup fields (which are actually records with nested properties).

    Solution Approach

    To group by the display values of the lookup columns (e.g., Operace.Nazev and VNKN.Seznam), you need to extract those values first using AddColumns, then group by the new columns.


    Suggested Formula

    ClearCollect(

        groupOpe,

        AddColumns(

            GroupBy(

                AddColumns(

                    OperaceVNKN,

                    OperaceNazev, Operace.Nazev,

                    VNKNSeznam, VNKN.Seznam

                ),

                "OperaceNazev",

                "VNKNSeznam"

            ),

            "skupOperace",

            CountRows(ThisRecord[@AllItems])

        )

    )

    🏷️ Tag me if you have any further questions or if the issue persists.
    ✅ Click "Accept as Solution" if my post helped resolve your issue—it helps others facing similar problems.
    ❤️ Give it a Like if you found the approach useful in any way.

     

     
  • Suggested answer
    Jon Unzueta Profile Picture
    1,827 Super User 2025 Season 2 on at
     

    Thanks for sharing your formula and context! You're close, but there are a few things to clarify when using GroupBy with lookup columns in Power Apps.

     Problem Breakdown

    You're trying to group a collection (OperaceVNKN) by two lookup columns: Operace and VNKN. However, GroupBy in Power Apps works best with text or primitive values, not complex records like lookup fields (which are actually records with nested properties).

    Solution Approach

    To group by the display values of the lookup columns (e.g., Operace.Nazev and VNKN.Seznam), you need to extract those values first using AddColumns, then group by the new columns.


    Suggested Formula

    ClearCollect(

        groupOpe,

        AddColumns(

            GroupBy(

                AddColumns(

                    OperaceVNKN,

                    OperaceNazev, Operace.Nazev,

                    VNKNSeznam, VNKN.Seznam

                ),

                "OperaceNazev",

                "VNKNSeznam"

            ),

            "skupOperace",

            CountRows(ThisRecord[@AllItems])

        )

    )

    🏷️ Tag me if you have any further questions or if the issue persists.
    ✅ Click "Accept as Solution" if my post helped resolve your issue—it helps others facing similar problems.
    ❤️ Give it a Like if you found the approach useful in any way.

     

     

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