+ Reply to Thread
Results 1 to 5 of 5

Using IF statement with Subtotal Result - nested subtotal not working

  1. #1
    Registered User
    Join Date
    01-31-2005
    Posts
    17

    Using IF statement with Subtotal Result - nested subtotal not working

    This is a "nested" subtotal problem.

    First of all - yes I know that subtotal will not include other subtotal functions in the same column.

    The main issue is that I am using a Subtotal function as part of an IF statement, and it's not adding up the non-subtotal part of the IF.
    If I change the Subtotal to be a SUM then it works as expected.
    I think, Excel is seeing the subtotal function anywhere in the formula and ignoring the entire cell.


    This is the formula in cell L5:
    =IF(AND(E5<>"",F5="Yes"),E5,SUBTOTAL(9,L6:L11))

    Explained: IF (E5 is not blank, and F5 is YES) then use the value in E5, if false, then subtotal L6:L11.

    to reproduce the problem create a subtotal of L4 to L12.
    It will not include the value in L5 if the statement is true.

    In layman's terms: If the user sets F5 to Yes, use the allowance amount in E5, if not calculate the subtotal for the lines below.


    I am assuming this is expected, but in all my years of Excel formulas, I've never seen this.

    Is there a way around this without using a 2nd column, to gather the amounts and total there?
    I have proved that if I use a 2nd column and just say that column = the column I want to total, it will work as needed.
    But that is a rebuild of the entire design.


    Regards,
    Sepp.

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Using IF statement with Subtotal Result - nested subtotal not working

    A master SUBTOTAL is always ignore any cells with sub SUBTOTAL inside, althought the sub TOTAL belongs to false statement of an IF.

    Try:

    =SUBTOTAL(9,L4:L12)+IF(F5="Yes",E5)
    Quang PT

  3. #3
    Registered User
    Join Date
    01-31-2005
    Posts
    17

    Re: Using IF statement with Subtotal Result - nested subtotal not working

    I'm just catching up on old threads.

    I saw your solution, but this would add the subtotal amount and the estimated amount, which is not the desired result.
    It's an either/or condition.
    Either use the estimated amount, or use the actual subtotal amount, but don't add the two together.

    In the end, we abandoned the logic of using an estimated total and moved the estimating into the detail of each section so that the subtotal formula is not conditional.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Using IF statement with Subtotal Result - nested subtotal not working

    Hi there.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 non-editable pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet complete with an explanation and some expected results.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    01-31-2005
    Posts
    17

    Re: Using IF statement with Subtotal Result - nested subtotal not working

    Glenn, your response makes no sense.

    A> The question was answered - using subtotal anywhere in a formula prevents it from being added in other subtotals.
    B> The issue is moot as I changed the logic for my spreadsheet.

    No need to post a workbook or anything else.

    However, If I post in the future, I'll keep that in mind.

    Have a great summer.

+ 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. Sorting by Alpha, Adding Subtotal - then removing subtotal - variable data sets
    By gregg_grug in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-03-2019, 07:41 PM
  2. Im New...if subtotal exists then remove. if subtotal doesnt exist do nothing
    By ci89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2015, 04:53 PM
  3. Remove only 1 subtotal layer from Multi Nested Subtotal
    By goawohl in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 10-16-2014, 10:10 AM
  4. Replies: 1
    Last Post: 09-18-2013, 04:10 PM
  5. Replies: 8
    Last Post: 07-31-2012, 09:41 AM
  6. Subtotal - Delete zero Subtotal and prior rows that calculate to that zero Subtotal
    By Whatsherface in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2012, 08:37 PM
  7. Replies: 3
    Last Post: 03-08-2006, 05:25 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