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)

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Year[/TD]
[TD]Month[/TD]
[TD]Quater[/TD]
[TD]RepQua[/TD]
[TD]ID[/TD]
[TD]Value[/TD]
[TD]PrevValue[/TD]
[/TR]
[TR]
[TD]2015[/TD]
[TD]Jan[/TD]
[TD]Q1[/TD]
[TD]FY15Q1[/TD]
[TD]A1B[/TD]
[TD]10[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]2015[/TD]
[TD]Apr[/TD]
[TD]Q2[/TD]
[TD]FY15Q2[/TD]
[TD]B2C[/TD]
[TD]20%[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]2015[/TD]
[TD]Apr[/TD]
[TD]Q2[/TD]
[TD]FY15Q2[/TD]
[TD]C11A[/TD]
[TD]3%[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]2015[/TD]
[TD]May[/TD]
[TD]Q3[/TD]
[TD]FY15Q3[/TD]
[TD]H76[/TD]
[TD]4[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]2015[/TD]
[TD]June[/TD]
[TD]Q3[/TD]
[TD]FY15Q3[/TD]
[TD]J87Q[/TD]
[TD]62[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]2016[/TD]
[TD]Jan[/TD]
[TD]Q1[/TD]
[TD]FY16Q1[/TD]
[TD]A1B[/TD]
[TD]20[/TD]
[TD]should be 10[/TD]
[/TR]
[TR]
[TD]2016[/TD]
[TD]Apr[/TD]
[TD]Q2[/TD]
[TD]FY15Q2[/TD]
[TD]B2C[/TD]
[TD]5%[/TD]
[TD]should be 20%[/TD]
[/TR]
[TR]
[TD]2016[/TD]
[TD]Apr[/TD]
[TD]Q2[/TD]
[TD]FY15Q2[/TD]
[TD]C11A[/TD]
[TD]7[/TD]
[TD]should be 3%[/TD]
[/TR]
[TR]
[TD]2016[/TD]
[TD]May[/TD]
[TD]Q3[/TD]
[TD]FY15Q3[/TD]
[TD]H76[/TD]
[TD]54[/TD]
[TD]should be 4[/TD]
[/TR]
[TR]
[TD]2016[/TD]
[TD]June[/TD]
[TD]Q3[/TD]
[TD]FY15Q3[/TD]
[TD]J87Q[/TD]
[TD]70[/TD]
[TD]should be 62[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advance.
 
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

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]...id[/TD]
[TD]Type[/TD]
[TD]Value N[/TD]
[TD]Value P[/TD]
[TD]PrevValue[/TD]
[/TR]
[TR]
[TD]A1B[/TD]
[TD]N[/TD]
[TD]12[/TD]
[TD][/TD]
[TD]looking value 10[/TD]
[/TR]
[TR]
[TD]B2C[/TD]
[TD]P[/TD]
[TD][/TD]
[TD]23%[/TD]
[TD]looking value 20%[/TD]
[/TR]
[TR]
[TD]C11A[/TD]
[TD]P[/TD]
[TD][/TD]
[TD]5%[/TD]
[TD]looking value 3%[/TD]
[/TR]
[TR]
[TD]H75[/TD]
[TD]N[/TD]
[TD]7[/TD]
[TD][/TD]
[TD]looking value 4[/TD]
[/TR]
[TR]
[TD]8UP[/TD]
[TD]N[/TD]
[TD]14[/TD]
[TD][/TD]
[TD]looking value 105[/TD]
[/TR]
</tbody>[/TABLE]
 
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,226,840
Messages
6,193,281
Members
453,788
Latest member
drcharle

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