+ Reply to Thread
Results 1 to 7 of 7

Sumproduct Help - Referencing Text String

  1. #1
    Registered User
    Join Date
    09-15-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    33

    Talking Sumproduct Help - Referencing Text String

    Good Day,

    I am having issues with a sumproduct formula referencing a text string parced out from a pivot table.

    SUMPRODUCT(--('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND("Total",B75)-1))*--('Invoice Detail'!$H$5:$H$913>60)*--('Invoice Detail'!$H$5:$H$913<=90),('Invoice Detail'!$S$5:$S$913))-(SUM($M$6:$M74)-SUM($M$6:$M74))

    The highlighted is the part of the code that I know is the issue. In this case the value of B75 is "GLOBAL SHARED SERVICES Total". My other spreadsheet references only "GLOBAL SHARED SERVICES". I've tried parcing out the phrase in another column and referencing that cell, but that does not work either. Can someone please advise?
    Last edited by mrsogmax76; 04-08-2010 at 01:06 PM.

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: Sumproduct Help - Referencing Text String

    LEFT(B75,FIND("Total",B75)-1) will result in GLOBAL SHARED SERVICES_ (underscore added to show space). Find("Total",B75) results in the the location of the T. "-1" will result in the Space between the Services and Total. Change it to LEFT(B75,FIND("Total",B75)-2).

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

    Re: Sumproduct Help - Referencing Text String

    Quote Originally Posted by mrsogmax76 View Post
    =SUMPRODUCT(--('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND("Total",B75)-1))*--('Invoice Detail'!$H$5:$H$913>60)*--('Invoice Detail'!$H$5:$H$913<=90),('Invoice Detail'!$S$5:$S$913))
    On an aside - if using * there is no need for double unary also else you're needlessly repeating coercion - to explain by means of (overly) simplistic example:

    =--"1" -> 1
    ="1"*1 -> 1

    thus

    =--"1"*1

    involves one lot of unnecessary coercion

    On that basis, either:

    =SUMPRODUCT(('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND(" Total",B75&" Total")-1))*('Invoice Detail'!$H$5:$H$913>60)*('Invoice Detail'!$H$5:$H$913<=90),'Invoice Detail'!$S$5:$S$913)

    or

    =SUMPRODUCT(--('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND(" Total",B75&" Total")-1)),--('Invoice Detail'!$H$5:$H$913>60),--('Invoice Detail'!$H$5:$H$913<=90),'Invoice Detail'!$S$5:$S$913)

    (both of the above were adjusted re: your initial issue also - when applying a FIND in this manner it's often a good idea to append the string with the search term so as to avoid possibility of error being generated (eg were B75 just equalled GLOBAL SHARED SERVICES - no Total)


    If you wanted to you could also replace:

    *('Invoice Detail'!$H$5:$H$913>60)*('Invoice Detail'!$H$5:$H$913<=90)

    with

    *(CEILING('Invoice Detail'!$H$5:$H$913,30)=90)
    Last edited by DonkeyOte; 04-08-2010 at 02:09 AM.

  4. #4
    Registered User
    Join Date
    09-15-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Sumproduct Help - Referencing Text String

    Quote Originally Posted by mdbct View Post
    LEFT(B75,FIND("Total",B75)-1) will result in GLOBAL SHARED SERVICES_ (underscore added to show space). Find("Total",B75) results in the the location of the T. "-1" will result in the Space between the Services and Total. Change it to LEFT(B75,FIND("Total",B75)-2).
    This worked perfectly. Thank you.

  5. #5
    Registered User
    Join Date
    09-15-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Sumproduct Help - Referencing Text String

    Quote Originally Posted by DonkeyOte View Post
    On an aside - if using * there is no need for double unary also else you're needlessly repeating coercion - to explain by means of (overly) simplistic example:

    =--"1" -> 1
    ="1"*1 -> 1

    thus

    =--"1"*1

    involves one lot of unnecessary coercion

    On that basis, either:

    =SUMPRODUCT(('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND(" Total",B75&" Total")-1))*('Invoice Detail'!$H$5:$H$913>60)*('Invoice Detail'!$H$5:$H$913<=90),'Invoice Detail'!$S$5:$S$913)

    or

    =SUMPRODUCT(--('Invoice Detail'!$V$5:$V$913=LEFT(B75,FIND(" Total",B75&" Total")-1)),--('Invoice Detail'!$H$5:$H$913>60),--('Invoice Detail'!$H$5:$H$913<=90),'Invoice Detail'!$S$5:$S$913)

    (both of the above were adjusted re: your initial issue also - when applying a FIND in this manner it's often a good idea to append the string with the search term so as to avoid possibility of error being generated (eg were B75 just equalled GLOBAL SHARED SERVICES - no Total)


    If you wanted to you could also replace:

    *('Invoice Detail'!$H$5:$H$913>60)*('Invoice Detail'!$H$5:$H$913<=90)

    with

    *(CEILING('Invoice Detail'!$H$5:$H$913,30)=90)
    Hi DonkeyOte,

    Can you please explain the ceiling function? Does it also work for trying to find values within a specific range?

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

    Re: Sumproduct Help - Referencing Text String

    CEILING is only really useful where there is an even pattern to the numbers of interest.

    In this case (>60 to <=90) CEILING was viable - rounding up all values to the lowest multiple of 30 >= current value.
    If follows that any value > 60 and <=90 would generate 90 ... all other values would generate values other than 90.

    (FLOOR does the same but in the opposite direction)

  7. #7
    Registered User
    Join Date
    09-15-2009
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: Sumproduct Help - Referencing Text String

    Thank you

+ 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