+ Reply to Thread
Results 1 to 10 of 10

Multiply based on criteria

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Multiply based on criteria

    Hi

    Im trying to make a formula that will multiply all numbers in an area based on a criteria, for instance multiply the numbers in column B in the below table based on the criteria "Blue" in column A. The formula should give the result 12, ie 2*3*2. Im familiar with the SUMPRODUCT but that will add the 3 numbers, ie 2+3+2, and I have also been messing with the PRODUCT formula and those 2 together, but I cant seem to make it work, so it multiplies the 3 numbers.

    Any help greatly appreciated


    A B
    1 Blue 2
    2 Red 2
    3 Blue 3
    4 Red 3
    5 Blue 2

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Multiply based on criteria

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

    This is an array formula.

    [Ctrl + Shift + Enter] to make it work.
    Attached Images Attached Images
    Last edited by davesexcel; 08-29-2015 at 08:51 AM.

  3. #3
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Multiply based on criteria

    Hi,

    This should do what you want:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    It's an array formula, so must be entered by pressing Ctrl-Shift-Enter not just Enter - curly brackets {} will appear round the formula (don't enter them manually) - if you press just Enter, you'll get the product of all the numbers (72). Drag it down to get the result for matching other criteria in column A.

    Blue 2 12 {=PRODUCT(IF(A$1:A$5=A1,B$1:B$5))}
    Red 2 6 {=PRODUCT(IF(A$1:A$5=A2,B$1:B$5))}
    Blue 3 12 {=PRODUCT(IF(A$1:A$5=A3,B$1:B$5))}
    Red 3 6 {=PRODUCT(IF(A$1:A$5=A4,B$1:B$5))}
    Blue 2 12 {=PRODUCT(IF(A$1:A$5=A5,B$1:B$5))}

    Edit: davesexcel got there first - the only difference between his and mine is that mine can be dragged down.

    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.
    Last edited by Aardigspook; 08-29-2015 at 08:54 AM. Reason: note previous answer

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Multiply based on criteria

    Another way to do it is to use a Pivot Table.

    1. Give your data column headings ('Colour' and 'Count' for example).
    2. Click any cell in the data area, go to the Insert tab and click 'Pivot Table' on the left-hand-side. The default option is for the Pivot Table to go on a new worksheet, but you can put it elsewhere on the same sheet if you want.
    3. On the right-hand-side, select both 'Colour' and 'Count'.
    4. You'll now see a table which has one column headed 'Sum of Count' with the values 7 and 5 shown against Blue and Red. Click either the 7 or 5, then go to 'Summarize Values By' (on the Pivot Table Tools | Options tab). Select 'Product' - the column will now read 'Product of Count' and have the values 12 and 6.

    Hope that's of some help too.


    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  5. #5
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Multiply based on criteria

    Thank you both very much - this was just what I was looking for.

    I gave you both rep, but as davesexcel got there first I will mark his answer as the solved one. Also thanks for the Pivot suggestion Aardigspook, but the array will work for me.

  6. #6
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Multiply based on criteria

    Hmn, thought I could put in another criteria like below with AND, but that is not working, can that be done?

    In this example the 2nd criteria is that B1:B5 should be less than 3, ie the result should be 2*2=4

    {=PRODUCT(IF(AND(B1:B5<3;A1:A5="Blue"),B1:B5)}

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

    Re: Multiply based on criteria

    Try this...

    =PRODUCT(IF((A1:A5="Blue")*(B1:B5<3),B1:B5))

    Still array entered.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Multiply based on criteria

    Glad to be of help and thanks for the rep.

    Regards,
    Aardigspook

    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark Thread as Solved'.
    You don't need to give me rep if I helped, but thanks are appreciated.

  9. #9
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Multiply based on criteria

    your suggestion works like a charm Tony, thanks

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

    Re: Multiply based on criteria

    You're welcome. Thanks for the feedback!

+ 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. autofilter with multiply criteria
    By ccsmith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2015, 12:53 PM
  2. Multiply rows based on Multiple Criteria
    By chacha123 in forum Excel General
    Replies: 3
    Last Post: 02-12-2015, 09:09 AM
  3. If criteria match, multiply then sum across multiply worksheets
    By ciayers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2013, 02:20 PM
  4. Multiply based on multiple array criteria
    By jcullen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2012, 06:14 PM
  5. how do i multiply based on 2 column criteria?
    By gjjh25 in forum Excel General
    Replies: 3
    Last Post: 11-24-2011, 09:58 AM
  6. Multiply COUNTIF by criteria in same row.
    By Belfast_stu in forum Excel General
    Replies: 11
    Last Post: 02-10-2011, 05:30 PM
  7. Replies: 1
    Last Post: 06-25-2010, 02:39 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