web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Grouping 2 tables data...
Power Apps
Answered

Grouping 2 tables dataverse and count rows

(0) ShareShare
ReportReport
Posted on by 565

Hi everyone,

 

If I have these 2 tables in dataverse (Devices and Users), how can I get a collection with the count of devices by country?

 

ReportbyCountry.png

 

Thanks for any help!

Categories:
I have the same question (0)
  • Verified answer
    v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @EmilioRoqueta69 ,

     

    Please try this.

    ClearCollect(COL,ShowColumns(AddColumns(GroupBy(AddColumns(RenameColumns(Devices,"User","User2"),"Country",LookUp(Users,Users=User2,Country)),"Country","DeviceName"),"Total",CountRows(DeviceName)),"Country","Total"))

     

    Best regards,

    Rimmon

  • WarrenBelz Profile Picture
    154,488 Most Valuable Professional on at

    Hi @EmilioRoqueta69 ,

    Try

    AddColumns(
     GroupBy(
     AddColumns(
     Devices,
     Country,
     LookUp(
     Users As _Data,
     User = _Data.User
     ).Country
     ),
     Country,
     Data
     ),
     "Total",
     CountRows(Data)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • EmilioRoqueta69 Profile Picture
    565 on at

    Thank you Warren,

     

    This formula must to be applied to a collection?

    Devices and Users are dataverse tables, not collections.

  • WarrenBelz Profile Picture
    154,488 Most Valuable Professional on at

    Hi @EmilioRoqueta69 ,

    You can either collect with it or add it directly as the Items of a Gallery.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • EmilioRoqueta69 Profile Picture
    565 on at

    Amazing Rimmon,

     

    This is working great! Thank you!!

     

    ClearCollect(Devices,
    {DeviceName: "DEVICE01", User: "John" },
    {DeviceName: "DEVICE02", User: "Paul" },
    {DeviceName: "DEVICE03", User: "Melinda" },
    {DeviceName: "DEVICE04", User: "Susan" },
    {DeviceName: "DEVICE05", User: "Tom" },
    {DeviceName: "DEVICE06", User: "Emily" },
    {DeviceName: "DEVICE07", User: "Janet" },
    {DeviceName: "DEVICE08", User: "Bill" },
    {DeviceName: "DEVICE09", User: "Emily" },
    {DeviceName: "DEVICE10", User: "Anthony" },
    {DeviceName: "DEVICE11", User: "Emma" },
    {DeviceName: "DEVICE12", User: "Bill" },
    {DeviceName: "DEVICE13", User: "Stephen" },
    {DeviceName: "DEVICE14", User: "Emma" });

    ClearCollect(Users,
    {Country: "USA", User: "John" },
    {Country: "USA", User: "Paul" },
    {Country: "USA", User: "Melinda" },
    {Country: "UK", User: "Susan" },
    {Country: "USA", User: "Tom" },
    {Country: "UK", User: "Emily" },
    {Country: "CANADA", User: "Janet" },
    {Country: "CANADA", User: "Bill" },
    {Country: "MEXICO", User: "Anthony" },
    {Country: "USA", User: "Emma" },
    {Country: "MEXICO", User: "Peter" },
    {Country: "UK", User: "Stephen" });

    ClearCollect(COL,ShowColumns(AddColumns(GroupBy(AddColumns(RenameColumns(Devices,"User","User2"),"Country",LookUp(Users,User=User2,Country)),"Country","DeviceName"),"Total",CountRows(DeviceName)),"Country","Total"))

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard