+ Reply to Thread
Results 1 to 24 of 24

Whats wrong with this expression (VALUE).

  1. #1
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Whats wrong with this expression (VALUE).

    Hi all,

    Can anyone tell me why this expression fails with a #VALUE! Error:-

    =IF(H18="","",SUMPRODUCT(($C$18:$E$397=H18)*($D$18:$F$397)))

    If I've read up correctly, #VALUE! errors can be related to attempting to evaluate text and numeric cells within an expression. I am indeed trying to mix cells (Cols C, E & H are text, D, F and the receiving cell are numeric), however, I'm 100% sure it was working at one stage!.

    I'm also getting a #VALUE! error with this expression on the same sheet:-

    =I18*9-L18

    but I think that is due to Col L being the receiving cell for the top expression, so I guess I need to fix the top one first.

    Any pointers please.
    J.
    Last edited by Jo-Jo; 12-09-2009 at 04:32 PM. Reason: Message format

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Whats wrong with this expression (VALUE).

    By the sound of it you could replace the SUMPRODUCT with a SUMIF which will avoid the issue of non-numeric coercion (column E being the issue in the SUMPRODUCT)

    =IF(H18="","",SUMIF($C$18:$E$397,H18,$D$18:$F$397))

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Whats wrong with this expression (VALUE).

    If you have any text in the range D18:F397 (except text that could be coerced to numeric like a text formatted number) then that formula will fail, because you are trying to do a numeric operation on a text value, excel doesn't like that (and "text" also includes blanks returned by formulas)

    Better to use SUMIF, i.e.

    =IF(H18="","",SUMIF($C$18:$E$397,H18,$D$18:$F$397))

    Edit: Snap!

  4. #4
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Thanks DonkeyOte & daddylonglegs, your suggestion works fine.

    I have to admit, I can't figure out how the two expressions work the same with a multiply operator removed.

    Just when I think I'm starting to get the basics, something else confuses me and I stare at it for hours wondering how/why!

    Anyway, it works, so thanks again.
    J.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Whats wrong with this expression (VALUE).

    The SUMIF works and the SUMPRODUCT doesn't because of coercion.

    Consider A1:D3

    Please Login or Register  to view this content.
    The below will generate a #VALUE! error

    Please Login or Register  to view this content.
    Why ?

    Well the first array of values can be seen as

    {TRUE,FALSE,FALSE;FALSE,FALSE,TRUE;FALSE,FALSE,FALSE}
    ie basic Booleans based on your test

    The second array of values can be seen as

    {1,"c",7;2,"a",8;3,"b",10}
    ie the values within B1:D3

    Now we know that we can "coerce" Booleans to numerical equivalent by a number of methods - one of which is of course multiplication... so in the SUMPRODUCT we look to multiply array one by array 2 to give us our output ... this can thus be viewed as

    {TRUE*1,FALSE*"c",FALSE*7;FALSE*2,FALSE*"a",TRUE*8;FALSE*3,FALSE*"b",FALSE*10}
    Perhaps know the issue will seem obvious... you can't explicitly coerce a non-numeric string to a number, ie

    TRUE*"a" -> #VALUE! ... equiv. to =1*"a"
    Given that's what you're doing the SUMPRODUCT returns #VALUE! - it won't simply ignore the errors.

    It's perhaps worth pointing out at this point that given the Arrays used are of the same dimensions (3x3) you could revert to a double unary approach which would not explicitly coerce the summation range in this manner - eg

    Please Login or Register  to view this content.
    When it comes to the final evaluation the SUMPRODUCT will simply ignore non-numerics in your summation range (ie C1:C3).
    (why use * rather than -- ? well the * method does have some distinct advantages over the -- method - discussed in Bob Phillips' white paper as linked in my sig.)

    The double unary treatment of the summation range is in essence the same as that conducted by a SUMIF - this can be illustrated with a basic example of:

    Please Login or Register  to view this content.
    would simply yield 0 (not #VALUE!) - the values in the summation range have no numerical value.

    It just so happens in this instance - given the layout of your data - that you could use

    Please Login or Register  to view this content.
    Rather than the SUMPRODUCT - the sum_range in the SUMIF will by default assume same dimension as the (criteria) range - which in this case is 3x3

    The SUMIF will by the design of the formula look for matches of "a" in A1:A3, B1:B3, C1:C3 and sum associated values in column to the right (ie B1:B3,C1:C3,D1:D3 respectively)

    Given "a" will not exist in B1:B3 this is not an issue - ie the 2nd range will always return 0... and thus all that takes place is in effect

    The layout of the above is not the same as your example but the underlying principles are identical.
    Last edited by DonkeyOte; 12-10-2009 at 08:02 AM. Reason: changed in line arrays

  6. #6
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    DonkeyOte, thank you very much for the explanation.

    I would lie if I said I understood at first reading, but I do copy all the info you guys give me into one text file and study, albeit slowly, when the house is quiet... will do same with your latest.

    Thank you very much.
    J.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Whats wrong with this expression (VALUE).

    Just as a follow-up to what Donkeyote says......

    Sometimes you might want to sum multiple columns based on matching criteria in a single column, you can't do that with SUMIF or double-unary SUMPRODUCT so the suggested method is often like this

    =SUMPRODUCT((A1:A10="x")*B1:G10)

    That work's until you have any text in B1:G10, if you do then you can revert to an array formula, i.e.

    =SUM(IF(A1:A10="x",B1:G10))

    confirmed with CTRL+SHIFT+ENTER

  8. #8
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Thanks for the add-on daddylonglegs,

    I'm just going into a state of deep depression and going to string myself from the highest tree.

    I've got a few similar expressions (sumproduct) linked together and I must have messed something up, every time I change one, something else goes amiss and some won't let me change to sumif.

    Just when I was nearly finished

  9. #9
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Can anyone please tell me if the answer to the question below, is in the instructions above?

    I'm sure the answer is there and I have read and re-read and think I even understand, but I can't get it to adapt to what I'm trying to do... and I'm going bonkers trying!

    I have a similar expression as the first, with the addition of a simple evaluation, but I can't get it to return the numeric that it should. However I swap it around the best I can get is TRUE or FALSE.

    I have these expressions:-

    =IF(H18="","",SUMPRODUCT(($C$18:$E$397=H18)*($D$18:$F$397<>"")))
    =IF(H18="","",SUMPRODUCT(($C$18:$E$397=H18)*($D$18:$F$397>=5)))

    I've change them to SUMIF's like this:-

    =IF(H18="","",SUMIF($C$18:$E$397,H18,$D$18:$F$397))<>””
    =IF(H18="";"";SUMIF($C$18:$E$397,H18,$D$18:$F$397))>=5

    I've tried moving the last evaluation before the last bracket. I've been off reading about ISERROR and tried enclosing the expression with that (don't know if that was a valid option, but I couldn't get it to work).

    Am I missing the obvious again?!... I'm positive it's in the explanation above and I'm just a totally dummy for not seeing it.
    Last edited by Jo-Jo; 12-11-2009 at 12:09 AM. Reason: Message format.

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

    Re: Whats wrong with this expression (VALUE).

    You cannot convert those Sumproducts to Sumif because Sumif only takes one criteria range and one criteria.. you have 2 conditions (ie. 2 ranges and 2 criteria), therefore you need to use Sumproduct in this case.

    If you have XL2007, then you could use SUMIFS which allows multiple criteria..

    The samples by DonkeyOte and daddylonglegs above were all based on one condition, and one summing range.
    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.

  11. #11
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Ahhhh, thanks NBVC... I've been going mad trying to figure that out. I'm obviously stupid in a different way than I thought.

    Can I ask if I have any alternatives to sumproduct and sumif, so I can get rid of the VALUE error I was trying to solve in the original post... I cured one and it gave me these

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

    Re: Whats wrong with this expression (VALUE).

    Is it possible to see a sample workbook showing this issue?

  13. #13
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Its become a bit large (might be above the limit!) and I need to put my latst messing arounds back to some sense. I'll try to chop out the portion.

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

    Re: Whats wrong with this expression (VALUE).

    There is also, the array formula that daddylonglegs mentioned... it is a combination of Sum() and IF()

    If would be like this:

    =IF(H18="","",SUM(IF($C$18:$E$397=H18),IF($D$18:$F$397<>””,1))

    and

    =IF(H18="";"";SUM(IF($C$18:$E$397=H18,IF($D$18:$F$397>=5,1))

    both of these must be confirmed with CTRL+SHIFT+ENTER not just ENTER.

    Try those first.

  15. #15
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    I've chopped and cut one sheet which I've attached. The cell references are the same, some of the referenced cells have just been pasted onto the sheet so that it works.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Sorry NBVC,

    The forum locked up whilst I was sending and I didn't see your last message until it came back to life. I will try what you mentioned.

  17. #17
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Sorry NBVC,

    The forum locked up whilst I was sending and I didn't see your last message until it came back to life. I will try what you mentioned.

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

    Re: Whats wrong with this expression (VALUE).

    I checked against your sheet... these give results:

    =IF(H18="","",SUM(IF($C$18:$E$397=H18,IF($D$18:$F$397<>"",1))))

    and

    =IF(H18="","",SUM(IF($C$18:$E$397=H18,IF($D$18:$F$397>=5,1))))

    confirmed with CSE keys and copied down.

  19. #19
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    NBVC, yes that works, but I'm getting value errors in cols K & M (simple math functions) if cell E11 is less than 20 (4-20 range).

    I've chased this from the original sumproduct that I corrected, then it moved to these two that you have corrected, I thought that because they are no formula in these that the last problem would also correct those.

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

    Re: Whats wrong with this expression (VALUE).

    How about, doing the test for column H being blank or not..

    e.g in K18

    =IF(H18="","",I18-J18)

    and in M18:

    =IF(H18="","",I18*9-L18)

    copied down

  21. #21
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    I'll give that a go later today. It's 07:00am here and I've been at this for most of the last 18hrs and I'm just not thinking straight anymore .

    I'll let you know how I get on.

    Thanks yet again for your help NBVC (I'll look forward to the car repair section )

    G'night/morn everyone.

  22. #22
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Hi NBVC, all,

    Tried it and that worked too. Now I seem to have moved a problem to the last col, under certain conditions.

    I'm going to have another go today, if I can't get it this time, I'll try an alternative like putting it in dummy (do you call this 'helper') columns first or just doing away with part of it.

    Thanks everyone, much appreciated all the help again.
    J.

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

    Re: Whats wrong with this expression (VALUE).

    If you can tell us what conditions cause problems, we may be able to diagnose it better.

  24. #24
    Registered User
    Join Date
    11-13-2009
    Location
    España
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: Whats wrong with this expression (VALUE).

    Quote Originally Posted by NBVC View Post
    If you can tell us what conditions cause problems, we may be able to diagnose it better.
    Hi NBVC,

    Apologies for the delay in replying. I needed to turn my attention to repairing a mixing desk and snake that got damaged and was needed urgently by my band this w/end.

    I got everything else working nicely with the s/shhet. The only thing I found was the last Col in the example... if there are more entries in Cols D & F than required by cell E11, then Col O ( =SUMIF($C$18:$E$397;$H18;$D$18:$F$397) )displays residual data instead of blanking it out.

    This isn't going to be a problem, because (unless I forget to clear it) there shouldn't be any extra entries left in Cols D & F. I'm going to sit down this afternoon and check with different scenarios, but I think it's just a tidyness issue and affects nothing.

    Thanks again for all of your help.
    J.

+ 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