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 / Groupby - Summation
Power Apps
Answered

Groupby - Summation

(0) ShareShare
ReportReport
Posted on by 2,129

I find this Groupby feature very useful for data manipulation.

When I use Gallery to show "CitiesByCountry" (from Groupby collection) and wish to list out: By Country and Total Population (of all the cities of this country), I am stuck!

- Country can be shown easily with ThisItem.Country; What about the formula for the Summation of Population (of all the cities of the particular country?)


PK Hong

Categories:
I have the same question (0)
  • Verified answer
    Migrated_User Profile Picture
    2,129 on at

    To get the sum of the population you'll need to use the following expression

    Sum(<expression that gets the grouped table for the specific country>, Population)

     

    For example, if you have a gallery like the one below, with the Items property set to CitiesByCountry:

    The first text box (larger font) has its Text property set to ThisItem.Country. The second textbox (displaying the total population has the Text property set to Sum(ThisItem.Cities, Population).


    Carlos Figueira

  • Verified answer
    Migrated_User Profile Picture
    2,129 on at

    Thanks...MAGIC! MAGIC!

    I wrote the same formula Sum(ThisItem.Cities, Population) but it appeared to be error. WHY?

    But when I re-do as you said, OK!

    I guess, sometimes, as of my experience, I need to either RETYPE, or Quit the program and re-Load.

    Strange, Strange, Strange!

    BUT, anyway, thanks a lot.

    NB: In fact, I am grouping more than that, e.g.:ClearCollect(FarmHouse, Groupby(TableFarm, "FarmName", "HouseNo", "HouseQty), so that I can have double FILTERING of FarmName - then - HouseNo, to get the Sum of HouseQty.

    This is a very useful features for multi-layer data manipulation.

    Thanks.


    PK Hong

  • Brian1 Profile Picture
    2 on at
    Hi.. if you have a data source going to a collection - the collection is called SumSalesbyProduct, with three columns Product, Date, and Sales. How do I sum the sales per Product to get the overall sales per Product. Thanks.
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I do not know how to use the Collection for get a partial sum,

    but if you want to show the sum of a GroupBy function in a Gallery, you can use the AddColumns function to create a new field with the sum that can be used to show the sum of underlying data in the Gallery.

     

    The Gallery definition could for example be:

    Items = AddColumns(GroupBy(DATASOURCE, "FIELDTOGROUPBY","NAMEOFGROUP"),"SUMCOLUMN", Sum(NAMEOFGROUP, FIELDTOSUM))

     

    Then you can add a label in the gallery with:

    Text = Thisitem.SUMCOLUMN

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