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 / How to create a collec...
Power Apps
Answered

How to create a collection that counts the common values

(0) ShareShare
ReportReport
Posted on by 565

Hi,

 

I need to summarize the people that work in the same Department, in a dataverse table.

So, by example, I have this data in a dataverse table and I need to get the result table/collection.

 

Collection.png

I think that it can be solved by a collection right?

Because there is no way to create a SQL view inside the dataverse....  or yes ?

 

Thanks in advance

 

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

    Hi @EmilioRoqueta69 ,

     

    If there is no specific column, please try this.

     

    ClearCollect(COL,RenameColumns(AddColumns(Distinct(DataSource,Department),"Total",CountRows(Filter(DataSource,Department=Value))),"Value","Department"))

     

     

     

    Best regards,

    Rimmon

  • EmilioRoqueta69 Profile Picture
    565 on at

    Hi Rimmon,

     

    I replaced your formula with real values and I have this error message.

     

    Collection2.png

     

    In other hand, I put this formula and it has no error, but it does not count all the rows that I have.

     

    ClearCollect(
        MyCollection,
        DropColumns(
            AddColumns(
                GroupBy(Filter(Inventory_ManagedDevices, !IsBlank(cr815_department)),"cr815_department","Total"),
            "Count",CountRows(Total)
            ),
        "Total"
        )
    );
     
    Thanks for any help!
  • v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @EmilioRoqueta69 ,

     

    Please try.

    vmengmlimsft_0-1713258548966.png

    Or

    ClearCollect(
     MyCollection,
     ShowColumns( AddColumns(
     GroupBy(Filter(Inventory_ManagedDevices, !IsBlank(cr815_department)),"cr815_department","User"),
     "Total",CountRows(User)),"cr815_department","Total")
     
    );

     

     

    Best regards,

    Rimmon

  • EmilioRoqueta69 Profile Picture
    565 on at

    Hi Rimmon,

     

    Thanks for the help.

    Something is not working with the Filter.

     

    This formula using Filter, counts more rows than the second one, BUT there are more records to count:

     

    ClearCollect(
    MyCollection,
    ShowColumns( AddColumns(
    GroupBy(Filter(Inventory_ManagedDevices, !IsBlank(cr815_department)),"cr815_department","User"),
    "Total",CountRows(User)),"cr815_department","Total"));


    ClearCollect(
    MyCollection,
    ShowColumns( AddColumns(
    GroupBy(Inventory_ManagedDevices,"cr815_department","User"),
    "Total",CountRows(User)),"cr815_department","Total"));

     

    My dataverse table has 3000 rows.

    I did try to put a dataverse view (that filter the empty data) inside the formula, but it makes an error message.

  • Verified answer
    EmilioRoqueta69 Profile Picture
    565 on at

    This formula works !

     

    ClearCollect(MyCollection,RenameColumns(AddColumns(Distinct(Filter(Inventory_ManagedDevices, !IsBlank(cr815_department)),cr815_department),"Total",CountRows(Filter(Inventory_ManagedDevices,cr815_department=Value))),"Value","cr815_department"))

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard