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 use Average and...
Power Apps
Suggested Answer

How to use Average and Filter with Collect() and Tables

(0) ShareShare
ReportReport
Posted on by
I have a SharePoint list with two important columns: WeekRating (number) and Answer Date (Date)
 
I am struggling to work out how the Average method works
I want to get the average of the WeekRatings that reside inside each week block. For example: I have this working for the weeks but I'm not sure how to get the rest of this working:

Clear(RangeWeeks);
ForAll(Sequence(1 + DateDiff(MonDate1, MonDate2, TimeUnit.Days) / 7),
    
        Collect(RangeWeeks, 
        { 
            WeekStart: DateAdd(MonDate1, (Value - 1) * 7, TimeUnit.Days),
            Score: Average(ShowColumns(Filter('Form Answers', AnswerDate >= DateAdd(MonDate1, (Value - 1) * 7, TimeUnit.Days) And AnswerDate <= DateAdd(DateAdd(MonDate1, (Value - 1) * 7, TimeUnit.Days), 6, TimeUnit.Days)), WeekRating))
        }))
 
Categories:
  • Suggested answer
    Mark Nanneman Profile Picture
    993 Moderator on at
    Your formula needs to be cleaned up quite a bit.  For one thing you're using the Average() function without giving it a column to average.  The way it's written you're just telling it to Show the WeekRating Column.  You can see this if you format your formula a bit:
     

    If you want to average "WeekRating" you need to put it in again as the second argument for the Average() function.
    e.g.

    That said your filters aren't delegable and won't work on large lists.

    I'm not 100% sure what you're going for, but using my best judgement I'd do something like this using two date pickers and a nested gallery:
     

    The formula for the gallery would be something like:
     
    With({
        MonDate1: DatePickerCanvas1.SelectedDate,
        MonDate2: DatePickerCanvas1_1.SelectedDate
        },
     
    AddColumns(
    GroupBy(
    AddColumns(
        Filter(
            'Form Answers Demo',
            AnswerDate >=MonDate1 And AnswerDate <= MonDate2
        ),
        Week, RoundUp(DateDiff(MonDate1,AnswerDate,TimeUnit.Days)/7,0)
    ),Week,'Forms For Week'
    ),'Week Score Avg',RoundUp(Average('Forms For Week',WeekRating),2)
    ))


    Hope that helps!

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 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard