+ Reply to Thread
Results 1 to 18 of 18

formulas calculating incorrectly

  1. #1
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    formulas calculating incorrectly

    Hello all.

    This is my first time utilizing this forum. First and foremost, I appreciate your time and input.

    Here's my issue: I'm using an excel spreadsheet/report generated from one of my colleagues in another department to pull out selective data. However, the formulas are calculating incorrectly. They don't seem to recognize the data from the report. For example, in one portion I'm trying to determine how many instances of a scenario occur within a certain date range. A simple array formula that has worked for me a thousand times before isn't in this spreadsheet (example below). I've made sure that the dates are formatted as such and other details I'm aware of that would affect these calculations.

    Can you assist me in trouble-shooting?

    Below is an example. Please keep in mind that when I open a new spreadsheet enter in dates and try these formulas out, they work fine. I'm perplexed.

    =SUMPRODUCT(--(D10:D183>=DATE(2009,8,9)),--(D10:D183<=DATE(2009,8,15)))

    My objective here is to count those dates that fall into the given date range. I'm then going to add another criteria, but this is a start.

    Thanks again!
    Last edited by Toidz77; 08-22-2009 at 09:36 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly-please assist

    We'll start off by asking if you have checked that Automatic calculation is on...

    Tools|Options.. Calculation Tab... Automatic must be selected.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Yes it's on. Another bit of information that may or may not be helpful came from my colleague today (he creates the initial report).

    I quote: "One thing I can think of is that when the data is transferred from SAS to Excel, it all gets turned into text. I don't know if this will help, but maybe converting the numeric rows to general or numeric will help your formulas function the way you expect. When I fixed the procedure date column this week, I changed the output format in SAS to dd-mmm-yyyy. When the dates were in Excel, I the column was converted from text to date with the VBA macro I have that formats the sheet."

    I tried his suggestion to no avail. Thank you very much for your input and guidance.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    Does this work?

    =SUMPRODUCT(--(D10:D183+0>=DATE(2009,8,9)),--(D10:D183+0<=DATE(2009,8,15)))

  5. #5
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Yes! THANK YOU!!!! Can you explain why? Also, if I want to include 1 more criteria, say an instance within the given date range that also has the term "Pre-procedure," what would the formula look like?

    Again, thank you.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    The +0 coerces the text string that looks like a number to be an actual number and so you can now compare to the dates (which are also numbers)...compare oranges to oranges... not apples to oranges...

    To add another condition, just simply add the condition like so...

    =SUMPRODUCT(--(D10:D183+0>=DATE(2009,8,9)),--(D10:D183+0<=DATE(2009,8,15)),--(E10:E183="Pre-procedure"))

    where E10:E183 is the range to review for matching that string...

  7. #7
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    I see now. I'm still wondering why manually changing the formats of the data to number didn't work. I guess it doesn't matter. I can't thank you enough for your help.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    Quote Originally Posted by Toidz77 View Post
    I see now. I'm still wondering why manually changing the formats of the data to number didn't work.
    you would have to change the format by selecting the column and going to Data|Text to Columns and clicking Finish... that should change the column to number format and your original formula should then work too...

    Also, don't forget to mark your thread as [Solved] see FAQ's in my sig to know how.

  9. #9
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Thanks again. It's almost solved. Once I add the text criteria, the formula no longer results in the correct answer. See general example below:

    Column G Column J
    Procedure Date Visit
    17-AUG-2009 Pre-Procedure
    17-AUG-2009 Pre-Procedure
    17-AUG-2009 Pre-Procedure
    17-AUG-2009 Pre-Procedure
    17-AUG-2009 Pre-Procedure

    My formula:
    =SUMPRODUCT(--(G3:G3000+0>=DATE(2009,8,17)),--(G3:G3000+0<=DATE(2009,8,17))--(J5:J3002="Pre-procedure"))

    The answer I recieve is 10, but it should be 5.

    Thanks!

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    Your last condition was offset by 2 rows down... maybe part of the problem

    =SUMPRODUCT(--(G3:G3000+0>=DATE(2009,8,17)),--(G3:G3000+0<=DATE(2009,8,17))--(J3:J3000="Pre-procedure"))
    Last edited by NBVC; 08-19-2009 at 03:31 PM.

  11. #11
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    No luck on the last suggestion unfortunately. I tried to attach a sample file here hoping it will help.

    Thanks again.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Just as the dates were not being recognized as numbers, the text doesn't seem to be recognized as text.

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    Not sure what you are showing me here

  14. #14
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Sorry. I removed any confidential data. Column G lists the of each event and column H lists the category. I want to calculate how many instances of a category occur within a certain date range. The weeks for this data run from Monday to Sunday. So if I wanted to calculate home many "Discharge" instances occured within the week of 10-Aug-2009 to 16-Aug-2009, I thought I could simple use the array formula I had used initially. This didn't work but then you added the "+0" which picked up the dates accurately. However, the text portion of the array doesn't work. I was hoping you could trouble shoot it. Thanks.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    Did you adjust the ranges and check your dates?

    Your less than or equal to date is the same as your greater than or equal to.. so it only actually looks for the data Aug 17, 2009 for matches.. is that supposed to be?

  16. #16
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    Yes I checked the dates. The example formula I provided was something I used because I knew there should only be 5 answers to it rather than 50+ (easier to check). Please use your Excel magic to guide me to resolution. Have you looked at my spreadsheet and had it work for you? This is killing me! Thanks a million.

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: formulas calculating incorrectly

    I don't see any August dates in your spreadsheet...

    another thing I noted about your formula is the absence of another comma separating the last argument:

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-18-2009
    Location
    Natick, MA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: formulas calculating incorrectly

    It was the comma. Thank you very much for all your time and guidance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1