Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 3XyX3K4z/TrrottyNITLNy
Power Apps - Building Power Apps
Answered

Question on how to display sum of only filtered table results

Like (1) ShareShare
ReportReport
Posted on 8 Feb 2025 20:05:44 by 14
I'm trying to get the sum of a column called "Hours Removed" in power apps to display the sum of the "removed hours" for associates listed as I filter the table by date range or by associate.
 
My table filters correctly as I need to by the date range or by associate name and list the hours already for each associate.  I just need to add in a display to show the sum of the "Hours Removed" column of the filtered table data.
 
Below is the table formula that I filter by that looks at the Associates name in the table and a date range formula that works well to sort the table .   
 
Any suggestion though on how to also have a text box to show the sum of hours of the "Hours Removed" column that are filtered in this table " "DataTable_Validations_Register"
 
 
Below is the table formula that I filter by that looks at the Associates name in the table and a date range formula that works well to filter the table data.
 
Sort(Filter(
    'Training Validations Correction Register',
    ThisRecord.Date >= DatePicker_From.SelectedDate,
    ThisRecord.Date < DatePicker_To.SelectedDate + 1  &&
     (
        IsBlank(txtSearchAssociate.Text) ||
        StartsWith(Associate.DisplayName, txtSearchAssociate.Text)
    )
),Date,SortOrder.Descending)
  • usoneillb Profile Picture
    14 on 10 Feb 2025 at 14:17:13
    Question on how to display sum of only filtered table results
    Thank you all thank worked.  I went with the one Infamous Let suggested.  I really appreciate everyones help.
  • Verified answer
    Infamous_Let Profile Picture
    155 on 08 Feb 2025 at 21:17:12
    Question on how to display sum of only filtered table results
    To display the sum of the "Hours Removed" column based on your filtered table, you can use the Sum function in a text label. Add a text label where you want the total to appear and set its Text property to the following formula:

    Sum(
        Filter(
            'Training Validations Correction Register',
            ThisRecord.Date >= DatePicker_From.SelectedDate &&
            ThisRecord.Date < DatePicker_To.SelectedDate + 1 &&
            (
                IsBlank(txtSearchAssociate.Text) ||
                StartsWith(Associate.DisplayName, txtSearchAssociate.Text)
            )
        ),
        'Hours Removed'
    )
    This formula filters your table using the same conditions you use to display the table data, then calculates the sum of the "Hours Removed" column from the filtered results. This will dynamically update the total whenever you change the date range or associate filter.
  • Verified answer
    WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 08 Feb 2025 at 21:15:14
    Question on how to display sum of only filtered table results
    Firstly, you can set the Default of txtSearchAssociate to "" (empty string) and save a bit of code (you do not need to test for Blank), but that is not your question. As Sum() may not Delegable (you did not state your data source), you can do this on a Label outside the Gallery.
    With(
       {
          _Data:
          Filter(
             'Training Validations Correction Register',
             Date >= DatePicker_From.SelectedDate &&
             Date < DatePicker_To.SelectedDate + 1  &&
             StartsWith(
                Associate.DisplayName, 
                txtSearchAssociate.Text
             )
          )
       },
       Sum(
          _Data,
          'Hours Removed'
       )
    )
    You may also want to try 
    Sum(
       YourGalleryName.AllItems,
       'Hours Removed'
    )
    but a trap here with a Delegable filter in the gallery (as in yours) is that initially only the first 100 records are displayed and the user has to scroll down to get each 100 batch (so the total may not be initially correct).
    I also assume here that Date (not a good name for a field) is a Date + Time field (hence the testing for the next day)
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

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

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading complete