Consulting

Results 1 to 8 of 8

Thread: how to calculate the weekly average of the last completed week

  1. #1

    Lightbulb how to calculate the weekly average of the last completed week

    I'll attached the file.this file will be updated every day. i wanna have the last weekly average but not last 7 days. current week shouldn't be counted. it must be an average from previous Monday to previous Friday i mean the last completed week.
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this array formula

    =AVERAGE(IF(($A$2:$A$2726>=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-6,"yyyymmdd")))*($A$2:$A$2726<=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-2,"yyyymmdd"))),$B$2:$B$2726))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Quote Originally Posted by xld View Post
    Try this array formula

    =AVERAGE(IF(($A$2:$A$2726>=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-6,"yyyymmdd")))*($A$2:$A$2726<=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-2,"yyyymmdd"))),$B$2:$B$2726))
    than you for replying but it didn't work could you please check it

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    The values in column A are not dates. You should convert these to dates and use a format of yyyymmdd if you want that appearance together with Date functionality.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by ffarshadd View Post
    than you for replying but it didn't work could you please check it
    Did you array-enter it?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Quote Originally Posted by xld View Post
    Did you array-enter it?
    i don't know how to do that i just copy that to an empty cell

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You put the formula in the first relevant cell, and instead of hitting Enter, you hit Ctrl-Shift-Enter all together. You will then see Excel wrap curly brackets around it in the formula bar. Then just drag-copy that cell to the rest.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could also use this

    =SUMPRODUCT(($A$2:$A$2726>=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-6,"yyyymmdd")))*($A$2:$A$2726<=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-2,"yyyymmdd")))*($B$2:$B$2726))/
    SUMPRODUCT(($A$2:$A$2726>=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-6,"yyyymmdd")))*($A$2:$A$2726<=--(TEXT(TODAY()-WEEKDAY(TODAY(),2)-2,"yyyymmdd"))))
    just copy it to the other cells.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •