Aggregate Function's Array Argument Gives VOLATILE formula result when using concatenation for Named Range

DR RENO

Board Regular
Joined
Jun 29, 2018
Messages
65
Need experts help on this after racking brain over and over. I have a data sheet, 'DATA', that contains Product and Pricing detail by row. Each row will have a column for Product Name (ie. Product A, Product B, Product C....etc), and a column for Location, (ie.Location 1, Location 2, Location 3....etc.) On another worksheet, I have a table that's a pricing schedule, 'PRICING SCHEDULE', for each product at each location. I've created a Named Range for each Product/Location line on the Pricing Schedule based on the previous product and location name example I gave looks like this: PRODA1, PRODB2, PRODC3. The pricing schedule will have the Price for the Product/Location combo.

The same product can be sold at multiple locations with a different price for each. So it will need a unique name in order to obtain the correct value. I'm using the Aggregate function in order to avoid having a longer formula with multiple IF Statements and And/OR operators. I'm just having trouble with the Aggregate functions array argument.

Aggregate works perfectly if I just directly type in the named range, but unfortunately, I have a dynamic file so I'm needing to reference in each data row the product and location to obtain the correct value from the other sheet. This has me creating a concatenation where I combine LEFT function to get the 1st 4 characters of the Product Name field and RIGHT function for the last character on both the Product Name field and the Location Name field. So for a row where the product is, 'Product B' for location 'Location 4', I get a concatenation of, ProdB4 which I have a named range setup as in the Pricing Schedule. Unfortunately, when I reference the cell that contains the concatenation, it generates a VOLATILE formula result. It also generates a Volatile formula result when entering the concatenation directly into the function's array argument. Here is my formula:

AGGREGATE(15,6,INDIRECT(CONCATENATE(LEFT(B2,4)&RIGHT(B2,1)&RIGHT(H2,1))/(CONCATENATE(LEFT(B2,4)&RIGHT(B2,1)&RIGHT(H2,1)))>$P2),1)


If I just type in PRODB4 where I am referencing my named range, the formula works perfectly, as the formula result give me a value. Again, I know there might be another formula option, but I don't want to get into a long IF statement, so would really need to keep using AGGREGATE. I am open to renaming the Named Ranges if you have a better suggestion, as well as obviously any formula changes you recommend.

Any help you can give with this will be greatly appreciated


 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I have to leave now - I'll try to help later. In the meantime try a formula with no structured references.

M.
 
Upvote 0
I've tried multiple modifications, but cannot get formula to cap on Largest value from array. Please let me know if you have another solution when you get a chance. Thanks. It's really close, except for that final piece.
 
Upvote 0
I'm confused - what exactly do you mean by "to cap the largest value from array"?

Try to show us the expected results (fill the cells with ?) and the logic to achieve such results.

[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #DCE6F1"][/TD]
[TD="bgcolor: #DCE6F1"]
Q
[/TD]
[TD="bgcolor: #DCE6F1"]
R
[/TD]
[TD="bgcolor: #DCE6F1"]
S
[/TD]
[TD="bgcolor: #DCE6F1"]
T
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
1
[/TD]
[TD]
Proposed Year 2​
[/TD]
[TD]
Proposed Year 3​
[/TD]
[TD]
Proposed Year 4​
[/TD]
[TD]
Proposed Year 5​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
2
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
3
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
4
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
5
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
6
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
7
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
8
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[TD]
?​
[/TD]
[/TR]
</tbody>[/TABLE]


M.
 
Upvote 0
Hi Marcelo,

Thanks for responding. Year10 on the Pricing Schedule is the highest price that should be on the data sheet's Proposed Year for the applicable Position and Location. Year 1 is the only column that can have a higher price since they transacted on it. Therefore there will be no price increase in the following years. If Year 1 is below the max price from Year 10 in Pricing Schedule, it increases will be the next highest in accordance to the pricing schedule. The formula solution you have provides that. The remaining issue is when that pricing increment has reached the max before Year4 in Datasheet, instead of getting a number error we just need the same value from prior year carried forward. Here is an example

Pricing schedule
[TABLE="class: cms_table_cms_table_grid, width: 0"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[TD]
C
[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]
Product​
[/TD]
[TD]
Location​
[/TD]
[TD]
Year1​
[/TD]
[TD]Year2[/TD]
[TD]Year3[/TD]
[TD]Year4[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 1​
[/TD]
[TD]100[/TD]
[TD]110[/TD]
[TD]115[/TD]
[TD]120[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 2​
[/TD]
[TD]150[/TD]
[TD]175[/TD]
[TD]200[/TD]
[TD]225[/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 3​
[/TD]
[TD]200[/TD]
[TD]210[/TD]
[TD]215[/TD]
[TD]220[/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 1​
[/TD]
[TD]95[/TD]
[TD]105[/TD]
[TD]120[/TD]
[TD]135[/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 2​
[/TD]
[TD]160[/TD]
[TD]200[/TD]
[TD]240[/TD]
[TD]280[/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 3​
[/TD]
[TD]205[/TD]
[TD]210[/TD]
[TD]215[/TD]
[TD]220[/TD]
[/TR]
[TR]
[TD]
8
[/TD]
[TD]
Product C​
[/TD]
[TD]
Location 1​
[/TD]
[TD]110[/TD]
[TD]115[/TD]
[TD]120[/TD]
[TD]125[/TD]
[/TR]
[TR]
[TD]
9
[/TD]
[TD]
Product C​
[/TD]
[TD]
Location 2​
[/TD]
[TD]148[/TD]
[TD]150[/TD]
[TD]160[/TD]
[TD]170[/TD]
[/TR]
</tbody>[/TABLE]

DATA Sheet

[TABLE="class: cms_table_cms_table_grid, width: 0"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[TD]
C
[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]
Product​
[/TD]
[TD]
Location​
[/TD]
[TD]
Year1​
[/TD]
[TD]Year2[/TD]
[TD]Year3[/TD]
[TD]Year4[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 1​
[/TD]
[TD]112[/TD]
[TD]115[/TD]
[TD]120[/TD]
[TD]120[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 2​
[/TD]
[TD]190[/TD]
[TD]200[/TD]
[TD]225[/TD]
[TD]225[/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]
Product A​
[/TD]
[TD]
Location 3​
[/TD]
[TD]217[/TD]
[TD]220[/TD]
[TD]220[/TD]
[TD]220[/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 1​
[/TD]
[TD]110[/TD]
[TD]120[/TD]
[TD]135[/TD]
[TD]135[/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 2​
[/TD]
[TD]160[/TD]
[TD]200[/TD]
[TD]240[/TD]
[TD]280[/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]
Product B​
[/TD]
[TD]
Location 3​
[/TD]
[TD]240[/TD]
[TD]240[/TD]
[TD]240[/TD]
[TD]240[/TD]
[/TR]
[TR]
[TD]
8
[/TD]
[TD]
Product C​
[/TD]
[TD]
Location 1​
[/TD]
[TD]110[/TD]
[TD]115[/TD]
[TD]120[/TD]
[TD]125[/TD]
[/TR]
[TR]
[TD]
9
[/TD]
[TD]
Product C​
[/TD]
[TD]
Location 2​
[/TD]
[TD]148[/TD]
[TD]150[/TD]
[TD]160[/TD]
[TD]170[/TD]
[/TR]
</tbody>[/TABLE]

I've tried putting in IF Statements, but could not get it to carry across. The tricky part, at least for me, is having the Position and location difference, where it will either use cell D2 or E2 depending on if it's a variable position or fixed price, in the file I had sent earlier.

Hopefully this clarifies a little better, but let me know if you need additional information. Thanks again for your help
 
Last edited:
Upvote 0
Let me clarify something after rereading my last message. The cell D2 or E2 reference has already been identified by your formula, so you're already grabbing the correct row in the Pricing Schedule. I shouldn't have said you will "either use cell D2 or E2" as your formula already has identified that. Apologize for adding confusion.
 
Upvote 0
Question
I'm assuming that the column C in Data sheet (Year1) is given.
If so, should the formulas calculate only the columns Year2, Year3 and Year4, right?

M.
 
Last edited:
Upvote 0
Technically correct. I have a formula in column C which is correctly capturing the applicable value(s). This will just be Year2 and outter years (year 3, year 4...etc)
 
Upvote 0
Try

DATA sheet

[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Product​
[/td][td]
Location​
[/td][td]
Year1​
[/td][td]
Year2​
[/td][td]
Year3​
[/td][td]
Year4​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
Product A​
[/td][td]
Location 1​
[/td][td]
112​
[/td][td]
115​
[/td][td]
120​
[/td][td]
120​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
Product A​
[/td][td]
Location 2​
[/td][td]
190​
[/td][td]
200​
[/td][td]
225​
[/td][td]
225​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
Product A​
[/td][td]
Location 3​
[/td][td]
217​
[/td][td]
220​
[/td][td]
220​
[/td][td]
220​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
Product B​
[/td][td]
Location 1​
[/td][td]
110​
[/td][td]
120​
[/td][td]
135​
[/td][td]
135​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
Product B​
[/td][td]
Location 2​
[/td][td]
160​
[/td][td]
200​
[/td][td]
240​
[/td][td]
280​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td]
Product B​
[/td][td]
Location 3​
[/td][td]
240​
[/td][td]
240​
[/td][td]
240​
[/td][td]
240​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td]
Product C​
[/td][td]
Location 1​
[/td][td]
110​
[/td][td]
115​
[/td][td]
120​
[/td][td]
125​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td]
Product C​
[/td][td]
Location 2​
[/td][td]
148​
[/td][td]
150​
[/td][td]
160​
[/td][td]
170​
[/td][/tr]
[/table]


Formula in D2 copied across and down
=IFERROR(AGGREGATE(15,6,'Pricing Schedule'!$C$2:$F$9/(('Pricing Schedule'!$A$2:$A$9=$A2)*('Pricing Schedule'!$B$2:$B$9=$B2)*('Pricing Schedule'!$C$2:$F$9>C2)),1),C2)

M.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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