+ Reply to Thread
Results 1 to 3 of 3

[SOLVED] SumProduct of Unique values in a dynamic length column

  1. #1
    Registered User
    Join Date
    03-09-2011
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2016, O365
    Posts
    18

    [SOLVED] SumProduct of Unique values in a dynamic length column

    I would like to make these formulas a more 'user friendly' since the data is dynamic from day to day.

    My formulas are:
    0: =SUMPRODUCT((B2:B246<>"")/COUNTIF(B2:B246,B2:B246&""))
    1: =SUMPRODUCT((B247:B2242<>"")/COUNTIF(B247:B2242,B247:B2242&""))
    2: =SUMPRODUCT((B2243:B4763<>"")/COUNTIF(B2243:B4763,B2243:B4763&""))
    3: =SUMPRODUCT((B4764:B8216<>"")/COUNTIF(B4764:B8216,B4764:B8216&""))
    4: =SUMPRODUCT((B8217:B8320<>"")/COUNTIF(B8217:B8320,B8217:B8320&""))
    5: =SUMPRODUCT((B8321:B8322<>"")/COUNTIF(B8321:B8322,B8321:B8322&""))

    I'm counting the unique values in column B where column K has a 0, 1, 2, 3, 4, or 5.
    The data I want to do the uniques count on will always start in B2, but one day there will be a 0 in column K down to row B246, K = 1 from row B247:B2242, K = 2 from row B2243:B4763, etc, then next day K = 0 from row B2:B432, K = 1 from B433:B3200, etc

    How can I change format of these formulas to autmatically find the dynamic range of 0, 1, 2, 3, 4, 5 without manually having to update the cell values in the formulas each day?

    Just because there is more than one way to find the count of unique values, I can also use these array formulas:
    {=SUM(1/COUNTIF(B2:B246,B2:B246))}
    {=SUM(1/COUNTIF(B247:B2242,B247:B2242))}
    {=SUM(1/COUNTIF(B2243:B4763,B2243:B4763))}
    {=SUM(1/COUNTIF(B4764:B8216,B4764:B8216))}
    {=SUM(1/COUNTIF(B8217:B8320,B8217:B8320))}
    {=SUM(1/COUNTIF(B8321:B8322,B8321:B8322))}

    So the same question here, How can I make these work with a dynamic range each day without manually entering the range?

    Thanks in Advance
    Don
    Last edited by ddander54; 12-23-2013 at 02:08 PM. Reason: [SOLVED]

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: SumProduct of Unique values in a dynamic length column

    Try this:
    =SUMPRODUCT((B2:B246<>"")/COUNTIF(B2:B246,B2:B246&""))
    replace with

    =SUMPRODUCT((INDEX(B2:B10000,MATCH(0,K2:K10000,0)):INDEX(B2:B10000, MATCH(0,K2:K10000))<>"")/COUNTIF(INDEX(B2:B10000,MATCH(2,K2:K10000,0)):INDEX(B2:B10000, MATCH(2,K2:K10000)),INDEX(B2:B10000,MATCH(0,K2:K10000,0)):INDEX(B2:B10000, MATCH(0,K2:K10000))&""))

    Others are similar, just replace your range of Bx:By with
    INDEX(B2:B10000,MATCH(A,K2:K10000,0)):INDEX(B2:B10000, MATCH(A,K2:K10000)) where "A" is either 0,1,2,3,4 or 5
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

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

  3. #3
    Registered User
    Join Date
    03-09-2011
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2016, O365
    Posts
    18

    Re: SumProduct of Unique values in a dynamic length column

    ChemistB,

    I had to make one minor change to get the formula to work, but now it does return a value and not a Div/0 error. Two of the Match lookup values was a 2, when we were solving for 0 in the first formula. Was that my test?

    It works perfectly now...

    Thanks,
    Don
    Last edited by ddander54; 12-20-2013 at 06:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 14
    Last Post: 11-04-2013, 08:16 AM
  2. [SOLVED] CountIF for dynamic length column using criteria of Named Range
    By saber0091 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-04-2013, 02:04 PM
  3. counting unique values in a variable length column
    By saimike in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-16-2012, 10:58 AM
  4. Dynamic column length in macro
    By Digger442 in forum Excel General
    Replies: 4
    Last Post: 06-06-2007, 02:40 PM
  5. [SOLVED] Macro code to autosum a dynamic length column
    By SlowPoke in forum Excel General
    Replies: 3
    Last Post: 03-31-2006, 06:55 PM

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