Calculated field that references a cell in that row, and the entire field

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Is it possible to reference a *cell* in a calculated field of access?

I want to add a column that takes the average of the "price" column, if the "product ID" column matches the "product ID" of that row, and the "date" column is less than the date in that row.

No.
Product ID
Date
Price
*12-month Avg - Prior to this Purchase*
Calculation
1
A
1/1/2016
10
= 0
2
A
5/30/2016
20
10
=AVG(1)
3
A
10/27/2016
30
15
=AVG(2, 3)
4
A
3/26/2017
40
25
=AVG(3, 4)

<tbody>
</tbody>
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
More information is needed, but check out the AVGIFS function.

Edit: sorry, AVERAGEIFS
 
Last edited:
Upvote 0
Is it possible to use AVERAGEIFS in Access?

I have a table of purchases with: Product ID, Date, and Price...for each purchase, I need to add a calculated column that shows the average price for the 12 months prior to that purchase date.
 
Upvote 0
That is an Excel function, and this is an Access question, no?
If the field you refer to is a table field, then you should not be storing calculated values in it. You can do calculations in a Totals query, averaging the price, Group By on Product ID, but I don't know what to suggest about your dates since it's not entirely clear to me what you want as results.
 
Upvote 0
Hi Micron,

Yes, this is an Access question. I have moved away from trying to add a calculated field in the last column of my table and I am now creating a query. My table has a record of all purchases made (over a 5 year period). For each purchase, I need to determine what the "average price paid over the 12-month period prior to this purchase" was. So, if one record represents: the purchase of an apple, on 1/1/2017...I need to determine the "average price paid for an apple over the 12 months prior to 1/1/2017". This will allow me to compare the price I paid on 1/1/2017 to the average price I paid for an apple in the previous year. This average price could be made up of 100+ purchase scattered across different dates within that 12 month period.
 
Upvote 0
But, I have many different products, so I cant explicitly refer to "apple" - I need to refer to the product in that row.
 
Upvote 0
Okay, I have a new thought/approach. In my table "Table1", I have added a "start date" and "end date"... so in my query, I have the Product ID, start date, and end date. So all I want to do is create a query that pulls the average price for the product ID between those dates. This should be possible in access, right? I am veryexcel minded so I am having trouble wrapping my head around access.
 
Upvote 0
Very possible, especially given the changes you made. The answer is in post#4. Totals query as suggested, but using your start and end date fields as WHERE parameters, not GroupBy or Aggregate function parameters. Either start with a query that includes your table and switch it to a Totals query (summation character in the ribbon) and choose these parameters from the combo selector in the Totals: row, or try the query wizard.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,689
Members
449,117
Latest member
Aaagu

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