Look up values of month from previous year

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I need to write a function, which find value from month from previous year:

Below is example of my data (I have year starting from 1992 - but it should not have meaning)

YearMonthQuaterRepQuaIDValuePrevValue
2015JanQ1FY15Q1A1B10-
2015AprQ2FY15Q2B2C20%-
2015AprQ2FY15Q2C11A3%-
2015MayQ3FY15Q3H764-
2015JuneQ3FY15Q3J87Q62-
2016JanQ1FY16Q1A1B20should be 10
2016AprQ2FY15Q2B2C5%should be 20%
2016AprQ2FY15Q2C11A7should be 3%
2016MayQ3FY15Q3H7654should be 4
2016JuneQ3FY15Q3J87Q70should be 62

<tbody>
</tbody>

Thank you in advance.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
are the values 10, 20% etc are all percentages or mixed with numbers?
 
Last edited:
Upvote 0
Hi,

If you assume that the Names ranges are as suggested this seems to work for me if you enter as an array (Control/Shift/Enter)

=SUM((Year=C11-1)*(Month=D11)*(ID = G11)*(Value))
 
Upvote 0
try this


Excel 2012
ABCDEFG
1YearMonthQuaterRepQuaIDValuePrevValue
22015JanQ1FY15Q1A1B10-
32015AprQ2FY15Q2B2C20%-
42015AprQ2FY15Q2C11A3%-
52015MayQ3FY15Q3H764-
62015JuneQ3FY15Q3J87Q62-
72016JanQ1FY16Q1A1B2010
82016AprQ2FY15Q2B2C5%0.2
92016AprQ2FY15Q2C11A70.03
102016MayQ3FY15Q3H76544
112016JuneQ3FY15Q3J87Q7062
Sheet2
Cell Formulas
RangeFormula
G7=SUMPRODUCT(--($A$2:$A$11=(A7-1)),--($B$2:$B$11=B7),--($C$2:$C$11=C7),--($E$2:$E$11=E7),$F$2:$F$11)


and conditional format column with cell value <1 with percentage


Excel 2012
ABCDEFG
1YearMonthQuaterRepQuaIDValuePrevValue
22015JanQ1FY15Q1A1B10-
32015AprQ2FY15Q2B2C20%-
42015AprQ2FY15Q2C11A3%-
52015MayQ3FY15Q3H764-
62015JuneQ3FY15Q3J87Q62-
72016JanQ1FY16Q1A1B2010
82016AprQ2FY15Q2B2C5%20%
92016AprQ2FY15Q2C11A73%
102016MayQ3FY15Q3H76544
112016JuneQ3FY15Q3J87Q7062
Sheet2
 
Upvote 0
thanks AlanY!

it's possible to modify:

- Type -> N it's number and column "Value N" has only number
- Type -> P it's percentage and column "Value P" has only percetage

...idTypeValue NValue PPrevValue
A1BN12looking value 10
B2CP23%looking value 20%
C11AP5%looking value 3%
H75N7looking value 4
8UPN14looking value 105

<tbody>
</tbody>
 
Upvote 0
this LONG formula that I'm sure someone can improve it should work without to seperate it into 2 columns and CF;


Excel 2012
ABCDEFG
1YearMonthQuaterRepQuaIDValue
22015JanQ1FY15Q1A1B10
32015AprQ2FY15Q2B2C20%
42015AprQ2FY15Q2C11A3%
52015MayQ3FY15Q3H764
62015JuneQ3FY15Q3J87Q62
72016JanQ1FY16Q1A1B2010
82016AprQ2FY15Q2B2C5%20%
92016AprQ2FY15Q2C11A73%
102016MayQ3FY15Q3H76544
112016JuneQ3FY15Q3J87Q7062
Sheet2
Cell Formulas
RangeFormula
G7=IF(SUMPRODUCT(--($A$2:$A$11=(A7-1)),--($B$2:$B$11=B7),--($C$2:$C$11=C7),--($E$2:$E$11=E7),$F$2:$F$11)<1,TEXT(SUMPRODUCT(--($A$2:$A$11=(A7-1)),--($B$2:$B$11=B7),--($C$2:$C$11=C7),--($E$2:$E$11=E7),$F$2:$F$11),0&"%"),SUMPRODUCT(--($A$2:$A$11=(A7-1)),--($B$2:$B$11=B7),--($C$2:$C$11=C7),--($E$2:$E$11=E7),$F$2:$F$11))
 
Last edited:
Upvote 0
which is the same as an extra column but more readable


Excel 2012
ABCDEFGH
1YearMonthQuaterRepQuaIDValue
22015JanQ1FY15Q1A1B10
32015AprQ2FY15Q2B2C20%
42015AprQ2FY15Q2C11A3%
52015MayQ3FY15Q3H764
62015JuneQ3FY15Q3J87Q62
72016JanQ1FY16Q1A1B201010
82016AprQ2FY15Q2B2C5%0.220%
92016AprQ2FY15Q2C11A70.033%
102016MayQ3FY15Q3H765444
112016JuneQ3FY15Q3J87Q706262
Sheet2
Cell Formulas
RangeFormula
G7=SUMPRODUCT(--($A$2:$A$11=(A7-1)),--($B$2:$B$11=B7),--($C$2:$C$11=C7),--($E$2:$E$11=E7),$F$2:$F$11)
H7=IF(G7<1,TEXT(G7,0&"%"),G7)
 
Upvote 0
also,

we can do like below:
Code:
=if(F2="N",
IF(SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$G$2:$G$16)<1,TEXT(SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$G$2:$G$16),0&"%"),SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$G$2:$G$16)),


IF(SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$H$2:$H$16)<1,TEXT(SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$H$2:$H$16),0&"%"),SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$H$2:$H$16)))

or
Code:
=IF(F2="N",SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$G$2:$G$16),SUMPRODUCT(--($A$2:$A$16=(A2-1)),--($B$2:$B$16=B2),--($C$2:$C$16=C2),--($E$2:$E$16=E2),$H$2:$H$16))
 
Upvote 0

Forum statistics

Threads
1,216,110
Messages
6,128,896
Members
449,477
Latest member
panjongshing

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