+ Reply to Thread
Results 1 to 5 of 5

Better Formula to Get Data Across Three Columns

  1. #1
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Better Formula to Get Data Across Three Columns

    Hello! This one has me stumped. I have a clunky formula that works, but I know there is something better:


    Column A values: only "A", "B", "C", but no particular pattern down the column (ABBBAAACCACB, etc.)
    Column B values: only "Add" "Increase" "Grow" "Subtract" "Remove" "Shrink"
    Column C: Just numbers (all 10's for this example).

    Task: For all the B's in Column A (for example), do what the B column says using the number in Column C.

    I have this formula in E4 for the A result, but it's really wordy:

    =SUMIFS(C2:C14, B2:B14, "Add", A2:A14, "A") +SUMIFS(C2:C14, B2:B14, "Increase", A2:A14, "A")+SUMIFS(C2:C14, B2:B14, "Grow", A2:A14, "A")-SUMIFS(C2:C14, B2:B14, "Subtract", A2:A14, "A")-SUMIFS(C2:C14, B2:B14, "Remove", A2:A14, "A")-SUMIFS(C2:C14, B2:B14, "Shrink", A2:A14, "A")

    Sample attached.

    I'd appreciate any help from the pros for shortening this up. Thanks!

    Regards, Leaning
    Attached Files Attached Files
    Last edited by leaning; 02-17-2015 at 07:11 PM. Reason: wording

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Better Formula to Get Data Across Three Columns

    Maybe this...

    =SUM(SUMIFS(C2:C14,B2:B14,{"Add","Increase","Grow"},A2:A14,"A"))-SUM(SUMIFS(C2:C14,B2:B14,{"Subtract","Remove","Shrink"},A2:A14,"A"))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Better Formula to Get Data Across Three Columns

    Tony,

    That is a lot shorter and works. I didn't know about that curly-brackets thing. Thanks!

    (BTW, what did we use before SUMIFS? (I have users who are still on Excel 97-03.))

    Regards,

    Leaning

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Better Formula to Get Data Across Three Columns

    These examples will work in every version of Excel.

    This array formula**:

    =SUM(IF(B2:B14={"Add","Increase","Grow"},IF(A2:A14="A",C2:C14)))-SUM(IF(B2:B14={"Subtract","Remove","Shrink"},IF(A2:A14="A",C2:C14)))

    Or, the same array formula** but using cells to hold the criteria...

    E2:G2 = Add, Increase, Grow
    E3:G3 = Subtract, Remove, Shrink

    =SUM(IF(B2:B14=E2:G2,IF(A2:A14="A",C2:C14)))-SUM(IF(B2:B14=E3:G3,IF(A2:A14="A",C2:C14)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    This normally entered version also using cells to hold the criteria...

    =SUMPRODUCT(--ISNUMBER(MATCH(B2:B14,E2:G2,0)),--(A2:A14="A"),C2:C14)-SUMPRODUCT(--ISNUMBER(MATCH(B2:B14,E3:G3,0)),--(A2:A14="A"),C2:C14)

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

    Re: Better Formula to Get Data Across Three Columns

    For what it's worth here's another array formula that concatenates the "+"s and "-"s. It uses this lookup table in L1:M4.

    Row\Col
    L
    M
    1
    Add +
    2
    Increase +
    3
    Remove -
    4
    Subtract -


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

+ 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: 0
    Last Post: 05-22-2014, 08:10 AM
  2. Replies: 9
    Last Post: 05-20-2014, 07:52 PM
  3. Formula to reproduce data from columns into new columns without #N/A
    By haralds in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-29-2014, 09:47 AM
  4. [SOLVED] Is a there a lookup formula I can use to match data from multiple columns of data?
    By missydanni in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2013, 08:27 AM
  5. Replies: 1
    Last Post: 02-13-2013, 03:37 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