AVERAGEIFS across two sheet range

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
923
Office Version
  1. 365
Hi,

I have the following input data in sheet 1:

Expense Tracker.xlsx
BCDE
1CategoryINRRMMYR/INR
2Total FundINR 40,000RM2,297.40₹ 17.41
3Total ExpenseINR 400RM22.97
4Daily AverageINR 200RM7.66
5BalanceINR 39,600RM2,274.42
6
7DateExpenseAmount (INR)Amount (RM)
8Saturday, 29 October, 2022Accommodation25014
9Sunday, 30 October, 2022Biscuit1509
10 
11 
12 
13 
Expense Journal
Cell Formulas
RangeFormula
D2:D3,D5D2=C2/$E$2
E2E2=E1.Price
C3C3=SUM(D8:D1000)
C4C4=AVERAGE(SUMIFS(D8:D200,B8:B200,UNIQUE(FILTER(B8:B200,B8:B200<>""))))
D4D4=Forecast!C4/$E$2
C5C5=C2-C3
E8:E13E8=IF(D8="","",D8/$E$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C5Cell Value>0textNO
C5Cell Value<0textNO
Cells with Data Validation
CellAllowCriteria
B8:B356List=Date
C8:C470List=Expense1


In sheet 2, I have another inout table as well:

Expense Tracker.xlsx
BCDE
7DateExpenseAmount (INR)Amount (RM)
8Tuesday, 1 November, 2022Lunch1509
9Wednesday, 2 November, 2022Lunch1408
10 
11 
Forecast
Cell Formulas
RangeFormula
B7:E7B7='Expense Journal'!B7
E8:E11E8=IF(D8="","",D8/$E$2)
Cells with Data Validation
CellAllowCriteria
B8:B459List=Date
C8:C459List=Expense1


I am trying to expand the AVERAGEIF formula in cell C4 from sheet 1 to include the entries in sheet 2 as well. The correct results will then be 172.5. Is there a way to accomplish this ? Appreciate the help.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You can simulate an AVERAGEIF with SUMIF/COUNTIF. So it could be (SUMIF(sheet1)+SUMIF(sheet2))/(COUNTIF(sheet1)+COUNTIF(sheet2)).
 
Upvote 0
Hi Auto,

Thank you. How would that incorporate the unique dates? The current formula calculates the average of the daily expense based on unique dates.
 
Upvote 0
Then it's probably SUM(UNIQUE(FILTER))) for each of them, divided by COUNT(UNIQUE(FILTER)))).
 
Upvote 0
Hi,

I tried as follows but its not working:

Excel Formula:
=AVERAGE(SUM(UNIQUE(FILTER('Expense Journal'!B8:B369,'Expense Journal'!B8:B369<>""))))+AVERAGE(SUM(UNIQUE(FILTER(B8:B369,B8:B369<>""))))/(COUNT(UNIQUE(FILTER('Expense Journal'!B8:B369))))+COUNT(UNIQUE(FILTER(B8:B369))))
 
Upvote 0
Thinking deeper about it, this method will count some days twice, so it may not work. Your best bet may be to combine the two sheets using either the VSTACK function (which may only work on 365 online excel) or - my personal favorite - Power Query.
 
Upvote 0
HI,

I have a cross post here:
 
Upvote 0
How about
Excel Formula:
=LET(vs,VSTACK(B8:D200,Forecast!B8:D200),f,FILTER(vs,INDEX(vs,,1)<>""),AVERAGE(BYROW(UNIQUE(INDEX(f,,1)),LAMBDA(br,SUM(IF(INDEX(f,,1)=br,INDEX(f,,3),0))))))
 
Upvote 0
Solution
Hi Fluff,

Thank you for the solution and that worked. Appreciate your patience and have a wonderful day ahead.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,682
Messages
6,126,195
Members
449,298
Latest member
Jest

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