+ Reply to Thread
Results 1 to 9 of 9

Sumproduct ignoring 0 values

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    53

    Sumproduct ignoring 0 values

    I have this formula:

    =SUMPRODUCT((InFill_Dates>=$A86)*(InFill_Dates<=$A86+6)*ISNUMBER((INDEX(Data_Table,,MATCH(D$1,Catagories,0)))))

    Which is counting the number of cells with a number in that fall between the specified dates (A86+6) and are under the category in D1. This is looking in a sepeate worksheet for the answers. This works great for all the currently entered data.

    I have set up the future cells to automatically source their data from elsewhere (this excel file runs very slowly, so by entering the data into a seperate file and then this file sourcing the data from that one it prevents the user from waiting for the cells to re-calculate every time data is entered). However, by setting up the formula it has generated a 0 in all the cells yet to be filled in the source file.

    This means that the above formula fills in the cells utilising the 0's - so currently the future displays a 7 for each week (1 0 for each day). I have tried hiding the 0's but the formula still recognises them. I was wondering if there was a way to modify the above formula to only count numbers 1 and above?

    Making a dummy workfile would be quite diffiicult so I will do my best to explain the problem, but I can do so if needed.

    Thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Sumproduct ignoring 0 values

    Attach a sample workbook with expected outcome for better understanding


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Sumproduct ignoring 0 values

    This is a very basic file, I can't replicate the actual file more closely, mainly because I'm not entirely sure how to.

    Sheet 1 is where you would put in a number into column B, C or D IF that particular category was present, so some days have 1 or more of the three categories present.

    Sheet 2 is used to calculate the number of times that category was present within the week. I can't use the formula pasted above because the actual file is far more complex and utilises and excel list and I don't know how to recreate that. But it works as I stated above, by taking the name of the category at the top of the column (category 1,2 or 3) and looking in the first sheet under that category between the date in column A + 6 days.

    The problem comes from row 17 downwards in sheet 1. In the actual file these cells are set to get their data from a seperate file and are all for future dates (thus you can input the data into the other file and then just update this one). Doing so fills all the cells with a '0' - which I have just done manually in the test file. This means that the formula auto fills in the future weeks in sheet 2 (and months in the actual file) as it counts the 0's as a number. Thus, the week commencing 28/01/2013 would displays a count of 4 in each category rather than remaining blank or at 0.

    One workaround is just to ignore the fictious data entered in the future and just wait until I have a weeks real data, enter it and then just work on that basis. But it would be nice to set the graphs up for the future as well so I never have to enter this file (it runs incredibly slowly).
    Attached Files Attached Files

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Sumproduct ignoring 0 values

    In B2 cell of Sheet2 cell
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Drag it down and right

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sumproduct ignoring 0 values

    Or, assuming you want a weekly sum, in B2 Drag Across then Down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sumproduct ignoring 0 values

    Or, assuming you want a weekly sum, in B2 Drag Across then Down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    or to get blank instead of zero
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Sorry about the double post, the forum hung on me yet again!
    Attached Files Attached Files
    Last edited by Marcol; 01-29-2013 at 07:45 AM.

  7. #7
    Registered User
    Join Date
    01-15-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Sumproduct ignoring 0 values

    You will have to forgive me as we have well and truly gone over my head. The formula that I pasted into the first message works perfectly for what I want it to do (except it factors in 0) - other than changing it to ignore 0 it must work in precisely the same way.

    From what I gather from looking at your two formula's is that they will work differently and not take into account the category of the column. There are about 10 columns in the second sheet and they are not all in the same order as in the first so this allows it to track the column across different sheets. The formula also accounts for the fact that there may be varying numbers of rows between two dates (in the example file, imagine if there were 1,2,3 or more rows for each date) - so the formula adapts to encompass all the rows required. Pasting your formula, sixthsense, returns a #Name? error - after changing the name of the data sheet.

    Looking at your code sixthsense I saw this <>"" which looks something like what I was expecting. I was attempting something along the lines of the exact same code but inserted somewhere a condition of >0. But I couldn't work out where to place it

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sumproduct ignoring 0 values

    Your original formula is referring to named ranges, I have added them to this workbook, "DataTable" & "Infill_Dates" are dynamic, depth-wise, so you can vary the depth without changing any formula.

    Are you summing or counting the data?

    See if this workbook helps, the first table sums the data, the second counts excluding zeros.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-15-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Sumproduct ignoring 0 values

    That works fine in the example you sent me, I copy and paste into a cell on the main file and get a #NAME? error. I made sure the cell references were correct for the date and category. I tried both the sum and count formulas. The error reporting isn't much use.

    I want to count, not sum.

    It also produces a #NAME? error in another column which sums the total count (so in the example it would sum the counts from category 1,2 and 3)

    Thanks

    Edit: evaluating the error shows that the #name? error comes from IF(#name?=0, "", SUMPRODUCT((InFill_Dates>=$A2)* - thus is the first bit of the formula regarding if the cell = 0.
    Last edited by Sinnie; 01-29-2013 at 09:34 AM.

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Sumproduct ignoring 0 values

    Look at the names manager in this workbook.

    You need to copy these names into your workbook, if they aren't in the workbook you'll get #NAME? errors.

    These names are now fully dynamic, add as many catagories and dates as you require, the named ranges will adjust to suit.
    Attached Files Attached Files
    Last edited by Marcol; 01-29-2013 at 10:06 AM.

+ 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