Question

I am trying to do the following:

  • For each Row
  • If Cell A contains text "abc" then get value on column B and
  • if value on Column B is > than 0:03:00 return 0.9
  • else if value on Column B is < 0:03:00 and > 00:01:00 return 0.6
  • else return 0.3
  • Sum the returned value with all the others.

The result should be something like:

=IF(ISNUMBER(FIND("abc",INDIRECT(""&$A16&""&"!$D$2:$D"))),IF(INDIRECT(""&$A16&""&"!$D$2:$D")>"00:0300,???,???),?etc??)

??? are the missing parts. Also, INDIRECT() could be removed for testing, but the problem is that ??? part. I have no idea how to get the result of the IF statement and how to process it. I suppose I don't understand how to work with columns.

Was it helpful?

Solution

You could possibly use an "array formula" with LOOKUP like this in excel

=SUM(IF(ISNUMBER(FIND("abc",A2:A100)),LOOKUP(B2:B100,{0,1,3}/1440,{3,6,9}/10)))

confirmed with CTRL+SHIFT+ENTER

or this version with IFs [edited]

=SUM(IF(ISNUMBER(FIND("abc",A2:A100)),IF(B2:B100>="0:03"+0,0.9,IF(B2:B100>"0:01"+0,0.6,0.3))))

In Google spreadsheets use this version

=arrayformula(SUM(IF(ISNUMBER(FIND(ʺabcʺ,A2:A100)),IF(B2:B100>=ʺ0:03ʺ+0,0.9,IF(B2:B100>ʺ0:01ʺ+0,0.6,0.3)))))

That will add 0.3 for the total for every row where "abc" is found in the text in column A and column B is >=0 but < 0:01, 0.6. where B >=0:01 and < 0:03 and 0:09 if B >= 0:09

Using LOOKUP makes it easier to avoid multiple IFs but I'm not sure if it gives the correct values for you on the boundaries, that's more easily adjustable with the second version. You can adjust the range lengths and add INDIRECT if required.

Note: using FIND for the first condition means that the formula will look for "abc" (case-sensitive) anywhere in the text, if you only want to check for exactly "abc" with no other text you can use just range = "abc" [not case-sensitive] or EXACT(range "abc") [case-sensitive]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top