+ Reply to Thread
Results 1 to 11 of 11

Subtotal with If (thought it was pretty straightforward but guess not!)

  1. #1
    Registered User
    Join Date
    02-18-2010
    Location
    T.O.
    MS-Off Ver
    MS 365
    Posts
    58

    Subtotal with If (thought it was pretty straightforward but guess not!)

    Hi guys,

    I'm trying to create a subtotal if Column A = 2017 and the formula seems pretty simple in my mind but guess not!

    =IF(A:A=2017,SUBTOTAL(9,BH:BH), 0)

    Help?

    Thanks!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Why SUBTOTAL? Why not SUMIF?

    =SUMIF(A:A,2017,BH:BH)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-18-2010
    Location
    T.O.
    MS-Off Ver
    MS 365
    Posts
    58

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Sorry, I should have clarified I am referencing a table with slicers and only want to captured filtered data.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    You could use SUMPRODUCT(SUBTOTAL(,OFFSET())) construct.
    Make sure that you don't use entire range, but only the range that encompass table range.

    See link for how it is used. If you need help in writing formula, please upload sample workbook.
    link removed

    EDIT: Detailed explanation of how the formula works is found below.
    https://chandoo.org/wp/formula-foren...ltered-tables/

    Another method is to add helper column that serves to indicate if row is filtered or not.
    Ex: in BI
    =SUBTOTAL(102,BH2)
    Copy down.

    Then use SUMIFS() checking for BI:BI = 1.
    Last edited by AliGW; 08-17-2018 at 12:41 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

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Please note rule 13:

    • Links in posts must be to relevant free solutions on your site.
    • Links in signatures must be to landing site of your blog that clearly promotes the free material above the commercial offerings.
    • Cross-promotion of, or links to, forums competitive to this forum in signatures or posts is prohibited.

    The Chandoo link is permissible as it's a tutorial, but the Mr Excel link to a forum thread is not.

  6. #6
    Registered User
    Join Date
    02-18-2010
    Location
    T.O.
    MS-Off Ver
    MS 365
    Posts
    58

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Here is my sample workbook. Thanks again for your help!!!
    Attached Files Attached Files
    Last edited by greentea; 08-17-2018 at 12:52 PM. Reason: Add attachment

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Thanks for the heads up Ali. Noted.

  8. #8
    Registered User
    Join Date
    10-19-2012
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    note i changed label in row 11.
    Attached Files Attached Files

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    See attached. I wasn't able to post formula due to firewall. See D18 to O20.

    Note: Table1[[Period]:[Period]] is used to make table structured reference absolute (i.e. does not change when copied across).
    Attached Files Attached Files

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Try in D12


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and ditto elsewhere.

    I suggest you tidy up your data. At the moment column A has both '2017' and '2018 BUD'....etc.
    Keep like things in their own column. So add an extra column for Type of item e.g. BUD, LE LY...whatever and keep column A just for a date/year..whatever.

    If you stat mixiing up dissimilar things in the same column you'll find yourself jumping through all sorts of hoops.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Subtotal with If (thought it was pretty straightforward but guess not!)

    Woops, I had error in the formula.

    In D18, AU$30 should be changed to AU$29. And then copied down and across.
    Last edited by CK76; 08-17-2018 at 01:51 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. What I though would be a very straightforward couple of lines of code....
    By Hastie73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2018, 12:03 PM
  2. A relative formula that isn't straightforward?
    By TFS2017 in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 09-15-2017, 06:12 AM
  3. [SOLVED] Adding in two blank rows using 2 If values (straightforward, I think....)
    By JerryWork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-29-2013, 06:44 AM
  4. Count of families whose members have gone to dentist. Straightforward?
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-06-2012, 09:22 AM
  5. I thought I was pretty good with excel... until...
    By Em Jaeh in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 10-27-2012, 01:35 AM
  6. Average Function-Pretty straightforward
    By RobDrew in forum Excel General
    Replies: 4
    Last Post: 04-30-2009, 08:29 AM
  7. straightforward.problem: Importing Excel spreadsheets
    By shilpashetty_80 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2008, 03:33 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