SUMIF (1 Viewer)

Erin M 2021

Member
Local time
Today, 15:20
Joined
Apr 14, 2021
Messages
77
Columns: AppealID, ExpenseCode, ExpenseAmt

There can be several Expense codes per AppealID but the AppealID table will change over time. How can I generically say SUMIF ("AppealID is the same",ExpenseAmt)

What I don't want to do is have to recode this each year when new AppealIIDs are added.

=SUMIF([AppealID],"Specific Appeal ID",[ExpenseAmt])


Thanks in advance.
 

Ranman256

Well-known member
Local time
Today, 16:20
Joined
Apr 9, 2015
Messages
4,337
its not excel, youd run a query that SUM(field),
then you can add an IIF( [sumOfFld1]<[sumOfFld2],"answer1", "answer2")
 

Erin M 2021

Member
Local time
Today, 15:20
Joined
Apr 14, 2021
Messages
77
its not excel, youd run a query that SUM(field),
then you can add an IIF( [sumOfFld1]<[sumOfFld2],"answer1", "answer2")
I only want to sum if the AppealID is the same. Not sum all.
 

plog

Banishment Pending
Local time
Today, 15:20
Joined
May 11, 2011
Messages
11,653
Please demonstrate your issue with data. Provide 2 sets:

A. Starting data from your table(s). Include table and field names and enough data to cover all cases.

B. Expected results of A. Show us what data you expect to end up with when you feed in the data from A into your query.

Again, 2 sets of data--starting and expected results.
 

Erin M 2021

Member
Local time
Today, 15:20
Joined
Apr 14, 2021
Messages
77
Please demonstrate your issue with data. Provide 2 sets:

A. Starting data from your table(s). Include table and field names and enough data to cover all cases.

B. Expected results of A. Show us what data you expect to end up with when you feed in the data from A into your query.

Again, 2 sets of data--starting and expected results.
EAppealIDExpenseAmt
G1$1,000.00
G1$600.00
G1$40.00
G1$42.00
G1$1,200.00
G1$1,400.00
F2$30.00
F2$300.00
F2$30.00
F2$150.00
F2$75.00
F2$400.00


EAppealIDExpenseAmt
G1$4,282.00
F2$985.00
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:20
Joined
Feb 19, 2002
Messages
43,337
It is not clear what your problem is but the solution is to store the variable amount when you add the record. The alternative is more complex and requires you to keep dated price change records so that the lookup always has to find the price at the time the record was created.
 

Erin M 2021

Member
Local time
Today, 15:20
Joined
Apr 14, 2021
Messages
77
It is not clear what your problem is but the solution is to store the variable amount when you add the record. The alternative is more complex and requires you to keep dated price change records so that the lookup always has to find the price at the time the record was created.
Not sure I understand. I'm wanting a query that sums if the appealID is the same. But we have new appealIDs frequently, so it needs to be a generic formula somehow.
 

Mike Krailo

Well-known member
Local time
Today, 16:20
Joined
Mar 28, 2020
Messages
1,044
Why wouldn't a simple totals query work based on the AppealID? Just group on AppealID.
 

Gasman

Enthusiastic Amateur
Local time
Today, 21:20
Joined
Sep 21, 2011
Messages
14,350
Am I missing something here?
A Group by query on EAppealID and sum of ExpenseAmt is all that is needed?
 

plog

Banishment Pending
Local time
Today, 15:20
Joined
May 11, 2011
Messages
11,653
Based on your sample data you just want a simple aggregate query:


Your explanation made it sound as if it was conditional on some values being equal, but nothing in your data demonstrates it. So this query will achieve what you want:

Code:
SELECT EAppealID, SUM(ExpenseAmt) AS TotalExpenses
FROM YourTableNameHere
GROUP BY EAppealID;

If that doesn't do it, please provide more sample data to demonstrate where the above query fails.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:20
Joined
May 7, 2009
Messages
19,247
maybe create a New table (tblGenericAppeal):

AppealNameEAppealID
AG1
BF2

then Join this table to your Expense table:

SELECT tblGenericAppeal.AppealName, Sum(Appeal_table.ExpenseAmt) AS SumOfExpenseAmt
FROM tblGenericAppeal INNER JOIN Appeal ON tblGenericAppeal.AppealID = Appeal_table.EAppealID
GROUP BY tblGenericAppeal.AppealName;


if EAppealID for "A" (or "B") changes, you add them to tblGenericAppeal table:

AppealNameEAppealID
AG1
BF2
AH3G1 was changes to H3
BJ4F2 was changed to J4


your above query will Still work! (provided the New EAppealID is not a "recycled" one).
 

Users who are viewing this thread

Top Bottom