Access previous record fields

paivers

Board Regular
Joined
Sep 4, 2009
Messages
64
I would like to have a calculated field use data from a previous row. An example is I want to get the payment method from the most recent customer sale. I know how to use maxx with a filtered set for this customer, to get the max date prior to this sale. But then I want to get the payment method from that previous sale. I am guessing I need to somehow get the previous sales ID, and use that to access that row to get the field. Any ideas how to approach this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
you'd need to use CALCULATE and then FILTER() using a column that somehow has some sort of sequence (numerical) so you can go forward or trying to get some sort of running total. It's hard to give you an exact formula but that's basically what I'd do in order to get the right context/filter.
 
Upvote 0
I could calculate/Filter is I had the previous key. The issue is that the only way to determine the most recent sale is using maxx(), but that just returns one value, the max date. I need a way to get that records identifier so that I can access it.
 
Upvote 0
you should check out the the Domain commands

something like

DGET(table, field, criteria) where the criteria is your MAX command

but i don't recall it being DGET ( which is excel) but i don't have Access to Access at the moment
 
Upvote 0
DGET sounds ideal, but unfortunately this is PowerPivot with DAX not Access. I don't see a DAX DGET formula, but an equivalent would work if anyone knows one.
 
Upvote 0
do you think that you could upload a copy of your workbook so I can take a look at it? can't visualize your pivot table nor data model right now
 
Upvote 0
do you think that you could upload a copy of your workbook so I can take a look at it? can't visualize your pivot table nor data model right now

Miguel,
Here’s an example using bicycle sales. I am trying to calculate the last field, Previous Type. To do that I filter by CustID to get the max date prior to the current, which gives row 1. From there I don’t know how to access the Type field of row 1. I suspect I need the SalesID, but it’s the same issue getting that.


SalesIDCustIDSalesDateTypePrevious Type
111/3/2013Hybrid
222/7/2013Mountain
315/2/2013RoadHybrid

<tbody>
</tbody>
 
Upvote 0
Paivers,

My apologies. I won't have time to look at anything during the next few weeks (busy days for business).
But I can tell you that you could use EARLIER in order to accomplish what you want.

Best of luck!
 
Upvote 0
Miguel,
Thanks, hopefully someone else can help. I do use EARLIER in the filter for compares, but I don’t see how that can be used outside of the filter context. My formula looks like this.


=MAXX(
FILTER('Sales',(
'Sales'[CustID] = EARLIER('Sales'[CustID]))
'Sales'[SalesDate] < EARLIER('Sales'[SalesDate]))
,'Sales'[SalesDate]
)

That returns the most recent SalesDate, now I need to find the Type on that date.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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