I have a data table with a listing of items (rows), years (rows), and periods of the year (columns). Something like this:
<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?
Item | Year | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
A | 2014 | 11 | 10 | 8 | 5 | ||||||||
A | 2013 | 5 | 5 | 5 | 5 | ||||||||
B | 2014 | ||||||||||||
B | 2013 | 2 | 3 | 4 | |||||||||
C | 2014 | ||||||||||||
C | 2013 | 5 | 5 |
<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?