+ Reply to Thread
Results 1 to 2 of 2

sumprod mistery

  1. #1
    Registered User
    Join Date
    10-28-2011
    Location
    Cluj-Napoca, Romania
    MS-Off Ver
    Excel 2010
    Posts
    1

    sumprod mistery

    Hey, I'm trying to sum different fractional values of elements from a column with a sumproduct formula. e.g.:

    A | B | C
    -------------
    1 | - | fcdef
    2 | - | cdfef
    1 | - | cdef

    The fractions are defined as the number of times the caracter "f" appears on the corresponding line in the C column divided by the total number of characters.

    For this example, the computation should go:

    1 * 2/5 + 2 * 2/5 + 1 * 1/4 = 0.4 + 0.8 + 0.25 = 1.45

    The formula I'm using is:

    =SUMPRODUCT(A:A, (LEN(C:C)-LEN(SUBSTITUTE(C:C,"f","")))/IF(LEN(C:C)>0,LEN(C:C),1))

    and the result is always the total number of occurrences of the "f" character in column C (7 in this case).

    If I split it into smaller formulas, they work just fine.
    If I generate the 2nd array from the sumproduct function in a column also behaves as expected, but I wouldn't like to create additional columns.

    Can somebody tell me what am I doing wrong or what's the way to do it?
    Thanks!

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: sumprod mistery

    Try this:
    =SUMPRODUCT(A1:A10,(LEN(C1:C10)-LEN(SUBSTITUTE(C1:C10,"f","")))/LEN(C1:C10))
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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