PDA

View Full Version : Using arrays to scale up binary formulas



nicksinthemi
03-14-2013, 07:53 AM
Hi all

Really interesting challenge here and any help even on where to start would be much appreciated.

So I have attached my spreadsheet. It's a dependency matrix that I invented and I'm trying to scale it up. I'm quite proud of it, but it is no longer fit for purpose.

This is the idea - there are activities which may have several dependencies. I want to translate the dependency matrix view to the week view telling me when the activity is 'ready'. 'Ready' is defined by the date at which the latest dependency exceeds a 3.

A data input sheet allows me to rate the maturity of these dependencies on a week by week basis. As soon as all dependencies reach a maturity level 3, that activity goes green on the BLOCK PLANNING sheet.

I used a bit of clever sheet copying and come conditional formatting to layer this up into several colours depending on the 'maturity level'.

My current solution is anything but elegant. I counted the rows for each activity set this up in an if clause to produce a binary result on the basis of a less than comparison. What does it compare against? Well, I basically multiply two IF conditions together for every cell in the DEPENDENCY MATRIX row. So if true it produces a 1x1 and then I add together these instances for the entire row. For that 1x1 the formula asks 'is the cell filled' on the one hand, and 'is the dependency for this week a 3 or above' on the other.

Finally, using excels $ logic I had my solution by dragging across. Beautiful. Actually pretty proud of this being a novice.

So now the challenge - expanding the columns to 100+

Problems: uses more than 64 nested ifs; the formula is also too long if I try to 'outsource' the if clauses to single cells of other sheets (though I had it there).

Question: is there a more elegant way of doing this at a larger scale in excel? Is VBA necessary or is there a better formulation?

SamT
03-16-2013, 01:48 PM
WOW!

SamT
03-16-2013, 01:54 PM
Is Sheet "TEST CASE BLOCKS" the Data Input sheet?
Is Sheet "DEPENDENCY PLANNING" the Dependency matrix Sheet?

SamT
03-16-2013, 03:02 PM
I can't even see an entire formula. Can't copy one either. WOW!

OK, I renamed the sheets to three characters and could see the entire formula.
I also inserted a column in Dependency Planning and two rows in Test Case Block so row and columns in Block Planning(n)swould align with the Row and column references to TCB and DP (see below)

By my vague understanding Sheets Block Planning (n) (BPn) look down each weeks column on Dependency Planning, (DP) and compare the value for each dependency to the constant in $B$2.

They look across Test Case Blocks (TCB) for each Actvity looking for non empty cells.
DP Rows.Count = TCB Columns.Count
Each Column in BPn corresponds to a column in DP and each Row in BPn does so for each Row in TCB

Your formulas appear to be

=If CountA(TCB.Row(n)) >
Count(DP.Column(n) > $b$2 And TCB.Row(n) <> "")
Then Result = 1
Block PLanning just adds the cell values in BPn's and conditionally formats the results.

How am I doing?

sassora
03-17-2013, 02:11 AM
Using an array formula you could use something like this:

=IF(COUNTA('TEST CASE BLOCKS'!$G5:$X5)>SUM(IF('DEPENDENCY PLANNING'!C$7:C$24>=$B$2,1,0)*IF(TRANSPOSE('TEST CASE BLOCKS'!$G5:$X5)<>"",1,0)),0,1)

paste it into D7 and press Ctrl-Shift and Enter keys. Then drag copy over the sheet.

I'd ideally like to suggest using countifs but it seems that you can't use horizontal and vertical ranges at the same time!

sassora
03-17-2013, 02:27 AM
If you wanted to avoid doing all the intermediate sheets you could paste:

=If(COUNTA( 'TEST CASE BLOCKS'!$G5:$X5)>SUM(IF('DEPENDENCY PLANNING'!C$7:C$24>=2,1,0)*IF(TRANSPOSE('TEST CASE BLOCKS'!$G5:$X5)<>"",1,0)),0,1)+
If(COUNTA( 'TEST CASE BLOCKS'!$G5:$X5)>SUM(IF('DEPENDENCY PLANNING'!C$7:C$24>=3,1,0)*IF(TRANSPOSE('TEST CASE BLOCKS'!$G5:$X5)<>"",1,0)),0,1)+
If(COUNTA( 'TEST CASE BLOCKS'!$G5:$X5)>SUM(IF('DEPENDENCY PLANNING'!C$7:C$24>=4,1,0)*IF(TRANSPOSE('TEST CASE BLOCKS'!$G5:$X5)<>"",1,0)),0,1)

into D7 of your "Block Planning" sheet (and then use Ctrl-Shift-Enter) and copy drag

SamT
03-17-2013, 09:34 AM
This can't be right

Your formulas appear to be

=If CountA(TCB.Row(n)) > _
Count(DP.Column(n) > $b$2 And TCB.Row(n) <> "") Then Result = 1

SamT
03-17-2013, 11:18 AM
date at which the latest dependency exceeds a 3. What do you mean by "Latest Dependency?"

Also I am looking at Activity 9 and it has several dependencies that have a maturity level of 2 in week one, but on the Block Planning sheet, Activity 9 is not highlighted until week nine. Why are you doing that?

IOW, why is it that the more dependencies an activity has, the later it is highlighted? It just seems backwards to me.

Analysis in progress notes:
wk 1, Activity 1, MaturityLevel (Mlvl) = 2
Dependency#(Dep#) [by Col in TCBs]
Counter(Ctr)
Mlvl = 2 to 4 [by Col in DP]
wk = By Column(1 to 52)

Block Planning[by wk] = IF COUNTA(Activity Dependencies[by wk])> Ctr Then 1
Calc Ctr:
IF Activity Has Dep1 => Mlvl Then Ctr+1
IF Activity Has Dep2 => Mlvl Then Ctr+1
IF Activity Has Dep3 => Mlvl Then Ctr+1
IF Activity Has Dep4 => Mlvl Then Ctr+1
IF Activity Has Dep5 => Mlvl Then Ctr+1
IF Activity Has Dep6 => Mlvl Then Ctr+1
IF Activity Has Dep7 => Mlvl Then Ctr+1
IF Activity Has Dep8 => Mlvl Then Ctr+1
IF Activity Has Dep9 => Mlvl Then Ctr+1
IF Activity Has Dep10 => Mlvl Then Ctr+1
IF Activity Has Dep11 => Mlvl Then Ctr+1
IF Activity Has Dep12 => Mlvl Then Ctr+1
IF Activity Has Dep13 => Mlvl Then Ctr+1
IF Activity Has Dep14 => Mlvl Then Ctr+1
IF Activity Has Dep15 => Mlvl Then Ctr+1
IF Activity Has Dep16 => Mlvl Then Ctr+1
IF Activity Has Dep17 => Mlvl Then Ctr+1
IF Activity Has Dep18 => Mlvl Then Ctr+1

18 Dependencies
52 wks
N Activities