getting excel to calculate correctly

pyclen

Board Regular
Joined
Jan 17, 2022
Messages
91
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi there,
I am still working on a workbook to calculate test cost at different times, something that is very often used in the pharmaceutical industry.

I copied a dummy example using XL2bb (below) however I try to explaijn what I want.

I have a column with tests, their difficulty, what department is performing this test, a surcharge, the hourly rate for the department, then setup hours and replicate hours.
For the # of setups column I have a formula that calculates the # of setups needed based on the product of columns J --> M.
The calculation works beautifully for T0 (column N) but I need to manually adjust it from T1 (column O) and beyond.

The number of samples for T1 and beyond comes from a separate table using a countA function, I have just created a dummy table below in row 11/12 indicating number of samples at each Tx.

My problem is that I need to adjust the number of setups for T1 and beyond manually instead of having it calculate based on the product of columns J -->M times x (value in row 12 for each time)

Is there a way to do that or am I stuck with manual adjustments?

any help for this novice that is trying to make a big contribution and learn new stuff is geratly appreciated
1647301734947.png




Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
2TestDifficultyGroupSurchargehourly ratesetup hoursreplicate hours#of setupsReplicates# of lots/strengthsOrientationsPackaging ConfigurationsT0T1t2T3T4T5t6t7t8setup hoursreplicate hours
3test 1avggrp110%$11010.515111$385surchargeGrouphr rateTestavghiavghi
4test 2higrp10%$10021.513111$6500grp1100test 111.50.51
5test 3avggrp120%$1203112111$6000.1grp2150test 21211.5
6test 4avggrp210%$1653113111$9900.2grp3175test 33411.5
7test 5higrp10%$1000.750.7515111$4500.3test 43512
80.4test 50.50.750.50.75
9at t1 I need to calculate the number of total samples to analyze and then adjust the number of setups based on that total.
10that goes for every time after t1
11stabilityT0T1t2T3T4T5t6t7t8t0 I can calculate easily
12# of samples133322211
13
14
Sheet1
Cell Formulas
RangeFormula
F3:F7F3=ROUND(IF(COUNTA($D3:$E3)<2,"",VLOOKUP($D3,group,2,0)*(1+$E3)),0)
G3:G7G3=IF($B3="","",INDEX(setup,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
H3:H7H3=IF($B3="","",INDEX(replicate,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
I3:I7I3=ROUNDUP(PRODUCT($J3:$M3)/10,0)
N3:N7N3=ROUND(PRODUCT($F3,SUM(PRODUCT($G3,$I3),PRODUCT($H3,$J3:$M3))),0)
Named Ranges
NameRefers ToCells
difficulty=Sheet1!$AE$3:$AF$3G3:H7
group=Sheet1!$Z$4:$AA$6F3:F7
rate=Sheet1!$AA$4:$AA$6F3:F7
replicate=Sheet1!$AG$4:$AH$8H3:H7
setup=Sheet1!$AE$4:$AF$8G3:G7
test=Sheet1!$AD$4:$AD$8G3:H7
Cells with Data Validation
CellAllowCriteria
C3:C7List=difficulty
D3:D7List=group
E3:E7List=surcharge
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

Can you explain exactly what needs to be adjusted from the formula in N column to O column and on?
Also, please explain the logic of your calculation in your N column formula.
 
Upvote 0
Hi there,
Column N is my base, there's nothing to change.

The next column (O) needs to take into account the change in the total number of samples being analyzed based on the product of D12 and J --> M.
In other words, the value in I3 needs to be dynamic for each time point, ie it needs to be calculated for each time.
If the formula can be adjusted for the initial time as well that is an option as well.
 
Upvote 0
I'm afraid I'm not following, again, please explain the logic for the required calculation, step by step, for column O, then, what changes for column P ?
Where is this "time" you speak of?

Don't forget, you know everything about your spreadsheet, potential helpers are Only relying on the information You provide in order to try to help.
 
Upvote 0
my apologies for being not as clear as possible.

I am trying to calculate the cost at various intervals (timepoints (T0, T1, T2, T3 etc (found in Column N2 --> U2, and C11 --> L11) for samples being tested.
I made an example sheet using test 1, 2, 3, etc. as example.
Each test has a setup time and replicate time (i.e. how often the test is performed (column J).
How often I need to perform a setup (akin to a reset of an instrument) is dependent on the total number of samples I need to analyze.
At my initial timepoint T0 the number of samples is C12*J3*K3*L3*M3 (1*1*5*1*1 = 5), and since I need to perform a reset after every 10 samples I just need to do it once.
So, the cost at T0 is F3*((g3*I3)+(h3*C12*J3*K3*L3*M3) = f3*(1+2.5) = 110 * 3.5 = 385

For T1 and subsequent times (T2/3/4 etc) that formula needs to be dynamic since D12, E12, F12 etc. may not be 1.
For T1 the value is D12*J3*K3*L3*M3 (3*1*5*1*1 = 15), therefore I need to perform 2 resets since 15>10 however the above formula that I used for T0 needs to be manually adjusted to account for the second reset.
F3*((g3*I3)+(h3*D12*J3*K3*L3*M3) = f3*(2+(0.5*15) = f3*(2+7.5) = 110 * 9.5 = 1045.

The same goes for subsequent times (T2/3/4...), how can I account for the changing value in D12/E12/F12 and resets I need to perform, i.e. make I3 dynamic
 
Upvote 0
Not 100% understanding, but below formula returns what you expected for T0 & T1:
sumeven.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1
2TestDifficultyGroupSurchargehourly ratesetup hoursreplicate hours#of setupsReplicates# of lots/strengthsOrientationsPackaging ConfigurationsT0T1t2T3T4T5t6t7t8setup hoursreplicate hours
3test 1avggrp10.111010.515111385104510451045660660660385385surchargeGrouphr rateTestavghiavghi
4test 2higrp1010021.5131116501550155015501100110011006506500grp1100test 111.50.51
5test 3avggrp10.212031121116001080108010808408408406006000.1grp2150test 21211.5
6test 4avggrp20.116531131119901980198019801485148514859909900.2grp3175test 33411.5
7test 5higrp101000.750.75151114501275127512758258258254504500.3test 43512
80.4test 50.50.750.50.75
9
10
11stabilityT0T1t2T3T4T5t6t7t8
12# of samples133322211
Sheet3
Cell Formulas
RangeFormula
F3:F7F3=ROUND(IF(COUNTA($D3:$E3)<2,"",VLOOKUP($D3,group,2,0)*(1+$E3)),0)
G3:G7G3=IF($B3="","",INDEX(setup,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
H3:H7H3=IF($B3="","",INDEX(replicate,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
I3:I7I3=ROUNDUP(PRODUCT($J3:$M3)/10,0)
N3:V7N3=$F3*($G3*ROUNDUP(HLOOKUP(N$2,$C$11:$K$12,2,0)*$J3*$K3*$L3*$M3/10,0)+$H3*HLOOKUP(N$2,$C$11:$K$12,2,0)*$J3*$K3*$L3*$M3)
Named Ranges
NameRefers ToCells
difficulty=Sheet3!$AE$3:$AF$3G3:H7
group=Sheet3!$Z$4:$AA$6F3:F7
rate=Sheet3!$AA$4:$AA$6F3:F7
replicate=Sheet3!$AG$4:$AH$8H3:H7
setup=Sheet3!$AE$4:$AF$8G3:G7
test=Sheet3!$AD$4:$AD$8G3:H7
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Not 100% understanding, but below formula returns what you expected for T0 & T1:
sumeven.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1
2TestDifficultyGroupSurchargehourly ratesetup hoursreplicate hours#of setupsReplicates# of lots/strengthsOrientationsPackaging ConfigurationsT0T1t2T3T4T5t6t7t8setup hoursreplicate hours
3test 1avggrp10.111010.515111385104510451045660660660385385surchargeGrouphr rateTestavghiavghi
4test 2higrp1010021.5131116501550155015501100110011006506500grp1100test 111.50.51
5test 3avggrp10.212031121116001080108010808408408406006000.1grp2150test 21211.5
6test 4avggrp20.116531131119901980198019801485148514859909900.2grp3175test 33411.5
7test 5higrp101000.750.75151114501275127512758258258254504500.3test 43512
80.4test 50.50.750.50.75
9
10
11stabilityT0T1t2T3T4T5t6t7t8
12# of samples133322211
Sheet3
Cell Formulas
RangeFormula
F3:F7F3=ROUND(IF(COUNTA($D3:$E3)<2,"",VLOOKUP($D3,group,2,0)*(1+$E3)),0)
G3:G7G3=IF($B3="","",INDEX(setup,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
H3:H7H3=IF($B3="","",INDEX(replicate,MATCH($B3,test,0),MATCH($C3,difficulty,0)))
I3:I7I3=ROUNDUP(PRODUCT($J3:$M3)/10,0)
N3:V7N3=$F3*($G3*ROUNDUP(HLOOKUP(N$2,$C$11:$K$12,2,0)*$J3*$K3*$L3*$M3/10,0)+$H3*HLOOKUP(N$2,$C$11:$K$12,2,0)*$J3*$K3*$L3*$M3)
Named Ranges
NameRefers ToCells
difficulty=Sheet3!$AE$3:$AF$3G3:H7
group=Sheet3!$Z$4:$AA$6F3:F7
rate=Sheet3!$AA$4:$AA$6F3:F7
replicate=Sheet3!$AG$4:$AH$8H3:H7
setup=Sheet3!$AE$4:$AF$8G3:G7
test=Sheet3!$AD$4:$AD$8G3:H7
THank you very much for your help, and I believe that is what I am trying to do
 
Upvote 0
Ok, I am grateful for the help received so far however the above solution only works on a single row (here row 12), i.e the calculation is correct in cell N4:N8, nowhere else as the test is different as well as the number of replicates.
The formulas in N4:N8 need to be modified so that the referenced test is correct as well as the timepoint in C8:K8

Again, any help is appreciated,
Thank you

Example.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAK
2setup hoursreplicate hours
3TestDifficultyGroupSurchargehourly ratesetup hoursreplicate hours#of setupsReplicates# of lots/strengthsOrientationsPackaging ConfigurationsT0T1t2T3T4T5t6t7t8surchargeGrouphr rateTestavghiavghi
4test 1avggrp10%1001111111$200$300$400$500$600$700$800$900$1,0000grp1100test 11111
5test 2avggrp10%1002211111$400$600$800$1,000$1,200$1,400$1,600$1,800$2,0000.1grp2150test 22222
6test 3avggrp10%1003311111$600$900$1,200$1,500$1,800$2,100$2,400$2,700$3,0000.2grp3175test 33333
7test 4avggrp10%1004411111$800$1,200$1,600$2,000$2,400$2,800$3,200$3,600$4,0000.3test 44444
8test 5avggrp10%1005511111$1,000$1,500$2,000$2,500$3,000$3,500$4,000$4,500$5,0000.4test 55555
9
10
11stability timepointsT0T1t2T3T4T5t6t7t8
12test 1123456789
13test 2123456789
14test 3123456789
15test 4123456789
16test 5123456789
17
18
19
Sheet1
Cell Formulas
RangeFormula
F4:F8F4=ROUND(IF(COUNTA($D4:$E4)<2,"",VLOOKUP($D4,$AB$4:$AC$6,2,0)*(1+$E4)),0)
G4:G8G4=IF($B4="","",INDEX(setup,MATCH($B4,test,0),MATCH($C4,Difficulty,0)))
H4:H8H4=IF($B4="","",INDEX(replicate,MATCH($B4,test,0),MATCH($C4,Difficulty,0)))
I4:I8I4=ROUNDUP(PRODUCT($J4:$M4)/10,0)
N4:V8N4=$F4*($G4*ROUNDUP(HLOOKUP(N$3,$C$11:$K$16,2,0)*$J4*$K4*$L4*$M4/10,0)+$H4*HLOOKUP(N$3,$C$11:$K$16,2,0)*$J4*$K4*$L4*$M4)
B12:B16B12=B4
Named Ranges
NameRefers ToCells
Difficulty=Sheet1!$AG$3:$AH$3G4:H8
group=Sheet1!$AB$4:$AB$6F4:F8
rate=Sheet1!$AC$4:$AC$6F4:F8
replicate=Sheet1!$AI$4:$AJ$8H4:H8
setup=Sheet1!$AG$4:$AH$8G4:G8
test=Sheet1!$AF$4:$AF$8G4:H8
Cells with Data Validation
CellAllowCriteria
B4:B8List=test
C4:C8List=Difficulty
D4:D8List=group
E4:E8List=surcharge
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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