Need help with a Powerpivot formula

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
609
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?
 

Tianbas

Board Regular
Joined
Apr 29, 2014
Messages
101
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
 

PentaGalCXO

New Member
Joined
Jan 31, 2012
Messages
46
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...
 

Forum statistics

Threads
1,078,541
Messages
5,341,061
Members
399,414
Latest member
EMW2159

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top