Forum Discussion

Shaney123's avatar
Shaney123
Copper Contributor
Oct 09, 2024

VLookup Formula

I need to lookup a weekday value (say Sunday) in column 2 then return the average of the "Sunday" values in column 3.   Can this also be done by using a cell to type in the number of weeks you wish to go backwards in history to create your average?  So the Vlookup would search Sunday's in column 2 then give me the historical Sunday averages for the number of weeks I put in the special cell.  Aka if I type in 4 it gives me the average of the previous 4-Sunday's. 

 

Date

Day of Week

Actual NCO

9/1/2024

Sunday

1,727

9/2/2024

Monday

3,306

9/3/2024

Tuesday

8,595

9/4/2024

Wednesday

7,704

9/5/2024

Thursday

8,005

9/6/2024

Friday

7,617

9/7/2024

Saturday

3,745

9/8/2024

Sunday

2,946

9/9/2024

Monday

7,128

9/10/2024

Tuesday

6,097

9/11/2024

Wednesday

5,486

9/12/2024

Thursday

6,176

9/13/2024

Friday

5,118

9/14/2024

Saturday

2,975

9/15/2024

Sunday

3,007

9/16/2024

Monday

5,548

9/17/2024

Tuesday

5,104

9/18/2024

Wednesday

4,794

9/19/2024

Thursday

4,946

9/20/2024

Friday

4,436

9/21/2024

Saturday

2,124

9/22/2024

Sunday

1,573

9/23/2024

Monday

4,898

9/24/2024

Tuesday

4,896

9/25/2024

Wednesday

4,693

9/26/2024

Thursday

4,532

9/27/2024

Friday

4,038

9/28/2024

Saturday

2,177

9/29/2024

Sunday

1,406

9/30/2024

Monday

4,990

10/1/2024

Tuesday

4,253

10/2/2024

Wednesday

4,347

10/3/2024

Thursday

4,179

10/4/2024

Friday

3,806

10/5/2024

Saturday

1,960

10/6/2024

Sunday

1,076

10/7/2024

Monday

3,961

10/8/2024

Tuesday

4,153

10/9/2024

Wednesday

4,649

10/10/2024

Thursday

4,385

10/11/2024

Friday

3,970

 

  • Patrick2788's avatar
    Patrick2788
    Silver Contributor

    Shaney123 

    If you're using Excel 365 (or 2021 or 2024) the best function for this task is FILTER.

     

    =LET(
        filtered, FILTER(Demo[Actual NCO], Demo[Day of Week] = input, 0),
        AVERAGE(TAKE(filtered, -previous))
    )

    The attached workbook will step you through the solution.

Resources