I'm working on a spreadsheet which will forecast the changes to certain costs in our building business based on estimated inputs.
For example, we may speculate that the price for a carpenter to complete a fitout will increase by $8 per m2 in Brisbane in August. We would write this data as:
- Area = Brisbane
- Month = August
- Cost Centre = Carpenter Fitout = 150
- We split each of the costs for building into different cost centres, represented numerically.
- Increase = $8
- Unit = m2
Based on this data, we can speculate how much each cost will increase in the coming months, and this is what I'm trying to do automatically.
The following are representations of the tables that I'm using in the spreadsheets.
Raw Data
An example of how the data looks raw from the import worksheet.
Area | Month | Centre | Value | Unit
-------|-----------|--------|-------|------
Bris | August | 150 | 10 | %
Sydney | September | 350 | 15 | m2
Import Table
How the data will be imported into the data analysing worksheet. The area, month and cost centre are combined for the VLOOKUPs later.
Label | Value | Unit
-------------------|-------|------
BrisAugust150 | 10 | %
SydneySeptember350 | 15 | m2
Calculation Table
All of the units that can be used in the import, and which calculation they correspond to. m2, m2t, m3, and EACH all use the same calculation (calc 4).
Unit | Calc | Description
-----|------|------------
FLAT | 1 | = Increase_Value
% | 2 | = Month_Value * Increase_Value / 100
000 | 3 | = Standard_Value * Increase_Value / 1000
m2 | 4 | = Standard_Value * Increase_Value
m2t | 4 |
m3 | 4 |
EACH | 4 |
Centre Values
Examples of standard quantities/dimensions that correspond to each of the cost centres.
Centre | Value
-------|-------
50 | 6
100 | 12
150 | 17
200 |
250 | ...
300 |
350 |
400 | etc
Monthly Data Dumps (For each Area)
Raw data is pasted into here from the live database at the beginning of each month to represent the costs associated with them.
July August September October
Centre
50 7 16 ... etc
100 68
150
200
250 ...
300
350
400 etc
Example Outputs
A summarised version of how the output will look, where each of the cost centres are against each of the months, and if there is something from the import that corresponds to both of these the appropriate calculation will be done.
Brisbane:
July August September October
Centre
50
100
150 10%
200
250
300
350
400
Sydney:
July August September October
Centre
50
100
150
200
250
300
350 15m2
400
Formula So Far
A psuedo-code version of the formula that will be featured in each cell so far. I thought it would be easier to decipher with labels instead of cell references, IFNA formulas taken out, etc.
=CHOOSE(
VLOOKUP( // Determine whether to use calc 1, 2, 3, or 4.
VLOOKUP( // Unit of calculation (i.e. m2, EACH, etc).
Area&Month&Centre,
Import_Table_Value,
3,
FALSE
),
Calculation_Table,
2,
FALSE
),
VLOOKUP( // Calc 1: Flat increase will only look up the increase value.
Area&Month&Centre,
Import_Value_Table,
2,
FALSE
),
( // Calc 2: % increase.
VLOOKUP( // Lookup the value from the monthly data dump corresponding to the appropriate month & cost centre.
Centre, // Cost centre (for each row).
Monthly_Data_Dump,
Appropriate_Month_Column,
FALSE
) * VLOOKUP( // Lookup the increase value.
Area&Month&Centre,
Import_Value_Table,
2,
FALSE
) / 100
),
( // Calc 3: 000' increase
VLOOKUP( // Lookup the appropriate value from the cost centre values table.
Centre,
Centre_Values,
2,
FALSE
) * VLOOKUP( // Lookup the increase value.
Area&Month&Centre,
Import_Value_Table,
2,
FALSE
) / 1000
),
( // Calc 4: Linear increase.
VLOOKUP( // Lookup the appropriate value from the cost centre values table.
Centre,
Centre_Values,
2,
FALSE
) * VLOOKUP( // Lookup the increase value.
Area&Month&Centre,
Import_Value_Table,
2,
FALSE
)
)
)
Basically, the formula will lookup a number from 1-4 and "choose" which formula will be used to determine a cell's value (if at all).
The spreadsheet has over approximately 300,000 cells to update across all the different areas, and running the formula as is takes an hour or more. I'm trying to reduce all the bloat and improve the time taken for the sheet to compute.
I've been dabbling with using INDEX MATCH instead of the VLOOKUPS, as well as trying some of the general optimisation tips that can be found online but the results only take off 5-10 minutes.
I'm after a more solid solution and am looking for advice on how to do that.