Need help with a Powerpivot formula

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
I have a data table with a listing of items (rows), years (rows), and periods of the year (columns). Something like this:

ItemYear121110987654321
A2014111085
A20135555
B2014
B2013234
C2014
C201355

<tbody>
</tbody>


What I want to go to, or as close as possible is, return for me the most recent month (and what that cost was) for the item ... looking back UP TO 12 months. For example, pretend we are in November 2014 (P11).

For item A, the last time a cost was seen was October 2014, so return that and the value 11.

For item B, the last time a cost was seen was November 2013, which is still within 12 months, so return that and the value 2.

For item C, the last time a cost was seen was September 2013, which is more than 12 months ago, so return "No cost" and 0 value.

What would be the best way to do this? Can it be done?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
It can be done but the best way is probably to bring the data in a format that powerpivot likes more than the table above. Try to get a table with only 4 columns (Item, Year, Month, Value). Add a calculated column to find the most recent row for each item using the EARLIER() function
 
Upvote 0
Ditto what Tianbas said, and if you can't get a better data source, use Power Query to unpivot the table you've shown. It has helped me many times. Works so well I get giddy every time I do it...
 
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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