+ Reply to Thread
Results 1 to 29 of 29

Using the same Data set from a subtotal formula to put into a sumproduct formula

  1. #1
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Using the same Data set from a subtotal formula to put into a sumproduct formula

    I have a spreadsheet with Subtotals already in it. I've come up with this formula:
    =SUMPRODUCT(SUBTOTAL(9,OFFSET($V$3,ROW(V4:V4)-ROW($V$3),0))*(R4:R4=$B$1))

    Which I inserted in the cell next to the subtotal formula:
    =SUBTOTAL(9,V4:V4)

    How do I repeat the SUMPRODUCT formula so it has the same data set range that the next SUBTOTAL uses?
    Attached Images Attached Images

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    g_data2017 welcome to the forum.

    You will need to upload a small sample *.xlsx Excel workbook file (desensitized). Pictures and screen shots are of little help. Additionally few are willing to retype so much data. This also allows us to see what you are working with in context.

    To attach a file to your post,
    • be sure to desensitize the data
    • click “Go Advanced” (next to Post Quick Reply – bottom right),
    • scroll down until you see “Manage Attachments”, click that,
    • click “Browse”.
    • select your file(s)
    • click “Upload”
    • click “Close window”
    • click “Submit Reply”

    The file name will appear at the bottom of your reply.
    Dave

  3. #3
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Thanks Flame,
    I followed your directions on how to upload the file.
    Attached Files Attached Files

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    In this part of the formula

    SUBTOTAL(9,OFFSET($V$2,ROW(V4:V4)-ROW($V$2),0))

    Can you tell us the logic behind the sudden change in cell W118 to

    SUBTOTAL(9,OFFSET($V$3,ROW(V119:V1410)-ROW($V$3),0))


    • Also it appears that you want the formula to execute on every row in column E that contains the word Total. Can you confirm?
    • Additionally is the choice of SUBTOTAL because you wish to ignore hidden rows?

  5. #5
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    The reason for the change in W118 is because that is where the next subtotal occurs. I want the formula to mirror the subtotal data set so when i filter the report it will filter the same data set that the subtotal filter does.
    Yes the formula would execute on every row that column E has the word Total.
    Yes i chose Subtotal so it would ignore the hidden rows, when i filter the report based on the date in column Q.

    I found a way to insert the formula at every total line, i just need to know how to create the formula so it mirrors the subtotal data set. I found a workaround that works, but it only works as long as the data set is no more than 296 rows. I can change it to more rows if necessary, but then this will slow down the performance of the report. Below is what I did.

    =SUMPRODUCT(SUBTOTAL(9,OFFSET($V$2,ROW(V4:V300)-ROW($V$2),0))*(R4:R300=$B$1)*(U3=U4:U300))

    To make the last criteria function I added in column U3, "=U4".

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    The reason for the change in W118 is because that is where the next subtotal occurs. I want the formula to mirror the subtotal data set so when i filter the report it will filter the same data set that the subtotal filter does.
    I don't follow. If that is the case then why doesn't it change at subsequent "next subtotals"? It remains $V$3 throughout the rest of the range in column W.

    Also I am so far stumped on how to do a dynamic range such as you describe with OFFSET. I'll keep working on it.
    Have you tried AGGREGATE? It has an option to ignore hidden rows.

    I can change it to more rows if necessary, but then this will slow down the performance of the report.
    I suspect that is because OFFSET is volatile. AGGREGATE is not.
    Last edited by FlameRetired; 05-19-2017 at 01:31 PM.

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Hmm, I'm confused as well.

    There's more than 1 HQ# within SUBTOTAL range. But you are ignoring all but the first one that appears after SUBTOTAL row. Is it intended?

    Edit: Doh! I misread the formula. Never mind.
    Last edited by CK76; 05-19-2017 at 01:47 PM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  8. #8
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    So this formula I found on a different excel website. I just plugged it in and then adjusted the reference points to fit the needs of the spreadsheet. The value $v$3 should be $v$2. I don't understand what it all means, but it just seems to work (blind luck I guess).

    I haven't tried aggregate. Mostly because like I said before I don't know understand what all of the values mean and do.

    Thanks for you help though. I spent two days on this and so I can appreciate the desires to finally solve a puzzle or answer the challenge.

  9. #9
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    No I want it to ignore all of the HQ other than the one that is reference in cell B1 within the subtotal range.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Wait... can't you just use SUMIFS?
    =SUMIFS($V$3:$V$1410,$E$3:$E$1410,LEFT(E3,6),$R$3:$R$1410,$B$1)

  11. #11
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Will this ignore any filtered rows when I filter on column Q "Rel Dt"? That's why I was using Subtotal instead.

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Ah got it. Is PivotTable an option?

    There are options, but the ones I can think of are volatile and will hamper performance.

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    @CK76

    I am not AGGREGATE proficient. Since it can ignore hidden rows I am exploring. Do you have any ideas?

  14. #14
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    I got one idea. Add helper column (W).

    In Newly added W column. It serves as flag if row is hidden or not.
    =SUBTOTAL(103, A3)

    In HQ Specific Amount column (Now X)
    =SUMIFS($V$3:$V$1410,$E$3:$E$1410,LEFT(E5,6),$R$3:$R$1410,$B$1,$W$3:$W$1410,1)

  15. #15
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    @FlameRetired

    I mostly use AGGREGATE for MAX, LARGE, SMALL, MIN. Can't seem to get SUM to take conditions. Will need to research a bit more on it.

  16. #16
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    PivotTable is not really an option. This report is currently being distributed to users. There was a request by the users to have the ability to see what a certain HQ had on order versus total orders during certain filtered time frames. Once they filtered the report to the certain conditions, they could then enter different HQ numbers to see the different HQ order quantities would be.

  17. #17
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Does helper column method work? Other than that, I'm out of ideas.

  18. #18
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    No it did not. It didn't error out, but all it did was come back with zeros, even though some of the rows should come back with something other than.

    Thanks for giving it a swing. I'll stick with what I've got. It's not ideal, but it seems to do the trick.

  19. #19
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    g_data

    Check cell W153. The formula is SUBTOTAL(9,OFFSET($V$3,ROW(V154:V238)-ROW($V$3),0))

    Shouldn't that be SUBTOTAL(9,OFFSET($V$3,ROW(V154:V166)-ROW($V$3),0))?

  20. #20
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Yes it should, but I don't want to have to go to each subtotal row and manually put in the correct data set range. I just did for the first couple of subtotal lines so I could see if it works. How do I construct a formula that I can just paste and drag down so it knows how to properly look for the answer?

  21. #21
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    I've tried everything I can think of. I can't get away from the SUBTOTAL/OFFSET to ignore hidden rows. It's in the attached.

    In W3 and filled down. When filtered for Contains: "total" it returns all blanks as it should.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Thanks for taking a crack at it.

    Maybe eventually they'll offer a wizard where we can enter a formula and have it put in the same way that subtotals are entered.

  23. #23
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Did that do what you want?

  24. #24
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    I got an error message. It doesn't like the last two Quotation marks in the formula sequence below.

    IFERROR(MATCH("*Total",$E4:$E$1410,0)-1,ROWS($E4:$E$1410)-1))=$B$1)),"")

  25. #25
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    I am not clear on that. Are you saying it did that in my upload? It doesn't at my end.

  26. #26
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    I was trying to access the file from an IE browser and got an error message. I copied the formula you listed out and tried to paste it into the spreadsheet and got the error. I tried chrome and was able to access the file. The formula looks good. I'll test it in another report with more rows to see if the formula causes any performance issues. Some of the reports have up to +68K rows.

    Thanks for your help!
    g-

  27. #27
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    Some of the reports have up to +68K rows.
    Yikes! You hadn't mentioned that before.

    Let us know how it does.

    This might benefit from a column ... perhaps several.

  28. #28
    Registered User
    Join Date
    05-18-2017
    Location
    California
    MS-Off Ver
    Office 2010
    Posts
    13

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    So it works when I first enter the equation, however as soon as I start to filter the results it cause the values to go blank. And when I try to clear out the filter it doesn't recalculate the values to the appropriate amount.

    I guess I could have mentioned that the files can be rather large at times. I had to parse the one I set you down, just so I could post it. I'll stick with what I original came up with since it doesn't seem to be too affected by the range I've set. I might tinker with expanding on the range just to see how much further I can take it before it starts to affect performance.

    Thank you.

  29. #29
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Using the same Data set from a subtotal formula to put into a sumproduct formula

    How are you filtering? Are you using the filter in the Data ribbon tab or the outline bars on the far left? They do different things.

    Also have you tried changing SUBTOTAL(103 to SUBTOTAL(3?

+ 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. [SOLVED] SUMIF or SUMPRODUCT or any formula for this data set?
    By millz in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-30-2016, 03:41 AM
  2. [SOLVED] Sumproduct or any other formula for filtered data
    By toci in forum Excel Formulas & Functions
    Replies: 29
    Last Post: 08-24-2016, 03:55 PM
  3. [SOLVED] sumproduct formula for horizontal data
    By Jules Pop in forum Excel General
    Replies: 7
    Last Post: 08-08-2014, 05:25 AM
  4. Best Formula... SUMPRODUCT with SUBTOTAL?
    By excellenthelp in forum Excel General
    Replies: 1
    Last Post: 12-19-2013, 04:14 PM
  5. Need Excel formula in Macro using Subtotal formula with If function
    By mbnewton1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-16-2013, 03:00 PM
  6. Replies: 2
    Last Post: 06-12-2012, 10:18 PM
  7. Custum subtotal formula for autofiltered data
    By 1eyedjack in forum Excel General
    Replies: 2
    Last Post: 02-08-2012, 11:14 AM

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