Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Excel Formula

I have a a spreadsheet where I am calculating elapsed time of calls.  I have one cell called Service avaiable date and time, cell AX, and another called IM Engaged date and time, cell AR.  Here are the scenarios I can run into:

Scenario #1
Service availble date, AX, can be null.  In this case the result should be 0:00:00

Scenario #2
IM Engaged date,cell AR, 07/16/2014 18:04 is greater then the service availble date, cell AX, 07/16/2014 17:35.  Result should be 0:00:00

Scenario #3
Service availble date,cell AX, is greater, 07/16/2014 18:04 then IM Enaged date,cell AR, 07/16/2014 17:35.  Result should be 0:29:00.

I tried a nested if formula, =IF(AX283="",0,IF(AR283>AX283,0,AX283-AR283) with no success.  What am I missing here?
0
Rrave26
Asked:
Rrave26
  • 5
  • 4
  • 2
1 Solution
 
rspahitzCommented:
I've seen cases where empty cells are not "" so that could be your problem here.  One way to solve that is to append "" in the test:

=IF(AX283 & ""="", ...

or you could try ISBLANK:

=IF(ISBLANK(AX283), ...
0
 
Rrave26Author Commented:
Ok, here is my formula:  =IF(ISBLANK(AX276),0,IF(AR276>AX276,0,AX276-AR276)).  Tried that and I get an Value error message.  Cell AX is null so I should get a value of 0 correct?
0
 
Ken ButtersCommented:
Point of clarification...

You are checking AR283>AX283.

The answer to whether one value is greater than another is true/false, will depend to a large extent on the data in the cell.   Is the data in your AR/AX cells formatted as date/time values or are they formatted as text values?

If they are formatted as text, you might be determining greater than or less than in terms of alphabetical order, rather than date/time order.

In addition if the cells are formatted as text... when you subtract the values... that will result in an error.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Rrave26Author Commented:
They are formatted as date time values.  They are all formated as mm/dd/yyyy h:mm.
0
 
Ken ButtersCommented:
if you put these formulas in some unused cells... what displays for each?

=ISBLANK(AX276)
=AR276>AX276
=AX276-AR276
0
 
Rrave26Author Commented:
Here are my results

=ISBLANK(AX276)  False
=AR276>AX276 False
=AX276-AR276  #VALUE
0
 
Ken ButtersCommented:
=AX276-AR276  #VALUE

This line would indicate that both cells do not contain values that excel recognizes as a date/time field.

Can you post back the results for these formulas? -- trying to figure which cell or cells do not contain dates (at least which ones Excel not recognize as dates).

=IF(NOT(ISERROR(DATEVALUE(TEXT(AR276,"mm/dd/yyyy")))),"valid date","invalid date")
=IF(NOT(ISERROR(DATEVALUE(TEXT(AX276,"mm/dd/yyyy")))),"valid date","invalid date")

In the scenario you are looking at for AR276, AX276 do you expect isblank(AX276) to return true?

(This might be easier to debug if you are able to post an example of your workbook that contanis the error).
0
 
rspahitzCommented:
=ISBLANK(AX276)  False

What do you see in AX276?
And what is the formula in AX276?  For formulas, Excel may interpret a "blank" as zero (0)
0
 
Rrave26Author Commented:
Here are the results:

=IF(NOT(ISERROR(DATEVALUE(TEXT(AR276,"mm/dd/yyyy")))),"valid date","invalid date")  "Valid"
=IF(NOT(ISERROR(DATEVALUE(TEXT(AX276,"mm/dd/yyyy")))),"valid date","invalid date")  "INvalid"

For the scenario with AR276, AX276 I did expect isblank(AX276) to return true.  But now I'm thinking that a "" doesn't return a value.  

I have attached my spreadsheet for review.  I am looking at the IM Raw Data tab.
Prouduction-IM-METRICS-T-V03.xlsm
0
 
Ken ButtersCommented:
Try this: (just changing the first If statement test to AX276=""

=IF(AX276="",0,IF(AR276>AX276,0,AX276-AR276))

The problem is... AX276 is not blank, because it contains a formula.  --- Even though the result of the formula is a blank.

Using the above format, you are specifically checking to see if a result of the formula is blank, rather than the cell  being blank.  (slightly different nuance).

Note... this looks very close to the formula in your original post that you already tried... only difference I can see, is that you were missing a trailing parenthesis.
0
 
Rrave26Author Commented:
This fixed my issue.  Thanks for the help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now