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 / Distinct & Sum vs Grou...
Power Apps
Answered

Distinct & Sum vs GroupBy & Sum

(0) ShareShare
ReportReport
Posted on by 23

Hi all!

My scenario is the following: Canvas App Embedded in a model driven app.

I am creating a gallery that has to show me items related to the record i am in, groping them by one of the fields and also get the sum of some fields in those records. I managed to do this easily with the GroupBy function and then adding a column where i make the sum of some fields from the related entities. In my opinion this is the best way to achieve this (see screenshot attached, I already have the result I need), however I was wondering whether I can avoid using the GroupBy and use a Distinct function.

The idea should be that when I do the distinct, the resulting table will have a column with the calculated sum ot the records.

Please let me know if there is a better way to do this using distinct or if I should stick with the working GroupBy.

 

Nik

 

screenshot group by.PNG
Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @nikongarato 

    GroupBy is most likely going to give you better performance in this scenario.

    If you use Distinct, you will only have the distinct values of a column.  You will then have to look up each record that matches that distinct value in order to sum it.

    GroupBy will return a table of the distinct values and all of the records that match that.  This you use then to calculate your sum.  

    It's one data operation versus many data operations.

     

    I hope this is helpful for you.

  • nikongarato Profile Picture
    23 on at

    Hi Randy!

    Yes I thought so, the way I already implemented seemed to me the most suitable. Just wanted another opinion.

    Thanks a lot for your feedback!

     

    Nik

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard