Filter/Matching HELP

Walker_Ice

Board Regular
Joined
Oct 6, 2023
Messages
50
Office Version
  1. 2021
Platform
  1. MacOS
Hi Everyone,

I recently created a table that counts based on the raw data available. Unfortunately, when I created the formula to find the average, I based it off of a table which already summed up the raw data based on month and year.
I would like to modify the formula to find the average based on the raw references that way its future proof and not relying on the table which will only be able to hold 4 years at a time.

Can someone help me modify the "Avg price per Appt" formula so that it references the raw data? References would be "Income_TotalPay & Income_Dates.

Any help would would be appreciated.



TEsting_Excel_File.xlsx
ABCDEFGHIJKLMNO
1Income_PayPaymentTipsIncome_TotalPayAppointment Analysis
2February 4, 2023$858.00$0.00$85.00Select Year:All
3March 13, 2024$750.00$250.00$100.00Month:# of ApptsAvg price per Appt
4June 17, 2023$75,000.00$25.00$100.00JAN0$0.00
5April 25, 2022$7,000.00$0.00$70.00FEB2$1,945.00
6May 17, 2023$85,000.00$5.00$90.00MAR1$11,355.00
7September 6, 2023$851,002.00$5.00$90.00APR1$74,876.00
8February 20, 2025$6,520.00$5.00$70.00MAY1$105,476.00
9JUN1$1,385.00
10JUL0$0.00
11AUG0$0.00
12SEP1$55,999.00
13OCT0$0.00
14NOV0$0.00
15DEC0$0.00
16
17
18
19
20
21
22Business Analysis
23Monthly Income ReportJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC
242022$0.00$0.00$0.00$4,300.00$88,888.00$0.00$900.00$750.00$999.00$0.00$0.00$0.00
252023$1,400.00$3,890.00$4,555.00$70,576.00$16,588.00$1,385.00$4,700.00$1,406.00$15,000.00$30,090.00$50,000.00$20,000.00
262024$0.00$0.00$6,800.00$0.00$0.00$0.00$0.00$0.00$40,000.00$0.00$0.00$0.00
272025$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00
Sheet2
Cell Formulas
RangeFormula
I4:I15I4=IF( $I$2="All", COUNT(FILTER(Income_Dates, MONTH(Income_Dates) = MONTH(DATEVALUE("1-"&TEXT($H4, "mmm")&"-2000")))), COUNT( FILTER( Income_Dates, (MONTH(Income_Dates) = MONTH(DATEVALUE("1-"&TEXT($H4, "mmm")&"-2000"))) * (YEAR(Income_Dates) = $I$2) ) ) )
J4:J15J4=IFERROR( IF( $I$2="All", SUM(INDEX($D$24:$O$27, , MATCH(H4, $D$23:$O$23, 0)))/I4, INDEX($D$24:$O$27, MATCH($I$2, $B$24:$B$27, 0), MATCH(H4, $D$23:$O$23, 0))/I4 ), 0 )
Named Ranges
NameRefers ToCells
Income_Dates=Sheet2!$A$2:$A$8I4:I15
Cells with Data Validation
CellAllowCriteria
I2ListAll, 2022, 2023, 2024, 2025
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
See if this does what you are after:
(Enter into J4)
If you are going to use a range name for the date column, you might want to use one for the Amount column as well, or convert the data to a table.

Excel Formula:
=IFERROR(
 IF(
    $I$2="All",
    SUM(FILTER($B$2:$B$8, MONTH(Income_Dates) = MONTH(DATEVALUE("1-"&TEXT($H4, "mmm")&"-2000"))))/I4,
    SUM(
        FILTER(
            $B$2:$B$8,
            (MONTH(Income_Dates) = MONTH(DATEVALUE("1-"&TEXT($H4, "mmm")&"-2000"))) * (YEAR(Income_Dates) = $I$2)
        )
    )
),0)
 
Upvote 0
Hi Alex, Thank you for your response. I think you are on the right track but there might some confusion. Let try and clarify as best as possible.

Income_Dates = A2:A8.
Income_TotalPay = D2:D8.

I need the "Avg Price per Appt" (Cell=J4), to search through Income_Dates for the Month in cell=H4 and the Year in cell=I2. Then Divide by the number of appts in cell=I4.
If the user selects "All" in cell=I2, then all sum all the payments for that month and all the years available.

I hope this helps. Below is how I modified the code you provided but it still did not work in my worksheet.
 
Upvote 0
Give this a try:

Excel Formula:
=LET(colPay,$D$2:$D$8,
    IFERROR(
        IF(
          $I$2="All",
          SUM(FILTER(colPay,MONTH(Income_Dates)=MONTH(DATEVALUE("1-"&TEXT($H4,"mmm")&"-2000"))))/I4,
          SUM(FILTER(colPay,(MONTH(Income_Dates)=MONTH(DATEVALUE("1-"&TEXT($H4,"mmm")&"-2000")))*(YEAR(Income_Dates)=$I$2)))/I4
),0)
)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top