+ Reply to Thread
Results 1 to 24 of 24

How to index match a value based on multiple columns ?

  1. #1
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    How to index match a value based on multiple columns ?

    I need to calculate the measure value based on 3 conditions in the excel sheet. If Type = Machine and MonthNumber = 1 and Label = LabelD then show the measure value. How can I write such formula ?

    HTML Code: 
    Attached Files Attached Files
    Last edited by donny007; 01-17-2019 at 08:47 PM.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: How to index match a value based on multiple columns ?

    so none of them fulfills the condition for this eg?
    =IF(AND(A2="machine",B2=10,C2="labeld"),D2,"")

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Sorry, I just edited my post again. It should be monthnumber = 1. Your formula doesn't capture the value within the range of values ?
    Last edited by donny007; 01-17-2019 at 08:53 PM.

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: How to index match a value based on multiple columns ?

    so your goal is to sum up the measures fulfilling those conditions? use SUMIFS instead.
    =SUMIFS(D:D,A:A,"machine",B:B,1,C:C,"labeld")

    do upload an excel sample so that we do not have to manually key in your data to do a testing.

    input the desired results so that we don't have to second-guess if what we are doing is correct or not. you may look at my signature to upload an eg that is easier to understand.

    the upload attachment must be done by going to Go Advanced. click on Manage Attachments. Choose file, upload and close the window.

    if i really guessed it wrongly, please upload something according to my recommendations. try to use the solution i have given and we'll help to advise what went wrong

  5. #5
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    I have uploaded the excel file to my original post. I don't want the sum. I just want the measure value based on the conditions.
    Last edited by donny007; 01-17-2019 at 08:53 PM.

  6. #6
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Can we write something like this ? But it doesn't return any value.

    =INDEX($D$2:$D$60,MATCH(3,($B$2:$B$60="1")*($A$2:$A$60="Machine")*($C$2:$C$60="LabelD"),0))

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: How to index match a value based on multiple columns ?

    Change the 3 to 1 just after the MATCH(, and use Ctrl-Shift-Enter to commit the formula, as it is an array formula.

    Hope this helps.

    Pete

  8. #8
    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
    43,984

    Re: How to index match a value based on multiple columns ?

    or... use this with enter, as normal:

    =INDEX($D$2:$D$60,MATCH(1,index(($B$2:$B$60="1")*($A$2:$A$60="Machine")*($C$2:$C$60="LabelD"),0),0))
    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

  9. #9
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,366

    Re: How to index match a value based on multiple columns ?

    Another option change your formula to this and this is array formula, so you need to press all together CTRL+ALT+ENTER button, when succes curly bracket will showed up

    =INDEX($D$2:$D$60,MATCH(1,($B$2:$B$60="1")*($A$2:$A$60="Machine")*($C$2:$C$60="LabelD"),0))
    Attached Files Attached Files
    Last edited by azumi; 01-17-2019 at 09:16 PM.

  10. #10
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Thanks guys! Your solutions worked perfectly.

  11. #11
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    As an extension to this

    I would like to add a filter(like a checkbox or a dropdown list)in the report. Column E (ClientName) should be the filter so the end users can select the value and filter the entire report.

    For example: If the user selects 'AK', the report returns data only related to AK. If the user selects 'BK', the report should return the data only related to BK.

    How can I do this ?

  12. #12
    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
    43,984

    Re: How to index match a value based on multiple columns ?

    SUMIFS is better by far for this whole thing, not INDEX-MATCH. Does this do what you wanted?
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Thank you Glenn! Could you tell me how did you create the drop down list filter ?

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: How to index match a value based on multiple columns ?

    As Glenn is off-line, I'll answer for him. You can see that Glenn has added a list of names in column P, and you can see on Name Manager that this has been given the name "List".

    Then on cell G1 if you click on Data | Data Validation you can see the option for List has been selected in the Allow box, and the Source for this is defined as =List (i.e. the named range defined above). This allows you to make selections from the drop-down which are restricted to allow only those values.

    Hope this helps.

    Pete

  15. #15
    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
    43,984

    Re: How to index match a value based on multiple columns ?

    Thanks, Pete.... I am far away from home... with limited www access, as power cuts are not infrequent here.

    But at 32C and sunny, it's better than an Irish (or Warrington) winter...

  16. #16
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Thanks Pete!

  17. #17
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    One more question, how can I filter the data in the sheet when I select a value from the drop down list ? For example If I pick the value from the drop down list as Q, then columns A,B,C,D,E should only show the data related to Q. If I pick the value from the drop down list as T, then columns A,B,C,D,E should only show the data related to T.

  18. #18
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: How to index match a value based on multiple columns ?

    I don't know of a way to do that in situ on the same sheet using a formula, but you could have a filtered list on another sheet which is governed by the drop-down (or it could be in a different area of the same sheet). Would this be acceptable?

    Pete

  19. #19
    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
    43,984

    Re: How to index match a value based on multiple columns ?

    So, which do you want to do... select "Q" from the dropdown, or from a filter?

  20. #20
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Select Q from the dropdown and see the 5 columns in the detail report changing.

  21. #21
    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
    43,984

    Re: How to index match a value based on multiple columns ?

    OK. You can do that... but the results will be on another sheet, or elsewhere on the same sheet. Your choice...

  22. #22
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Glenn: The results will be on another sheet.

    Thanks! I love Irish music by the way.
    Last edited by donny007; 01-18-2019 at 11:34 AM.

  23. #23
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: How to index match a value based on multiple columns ?

    I've set this up for you in the attached file. Rather than embed the choices with the SUMIFS formula, I've given you 4 drop-downs (yellow cells on Sheet2) which enable you to choose the options, or you can leave them blank to mean "All" values. These drop-downs are fed from the named ranges in columns K to O, with the names given on row 1.

    I have used a helper column on Sheet1 (main data sheet), with this formula in F2:

    =IF(AND(OR(E2=Sheet2!$E$1,Sheet2!$E$1=""),OR(C2=Sheet2!$C$1,Sheet2!$C$1=""),OR(B2=Sheet2!$B$1&"",Sheet2!$B$1=""),OR(A2=Sheet2!$A$1,Sheet2!$A$1="")),MAX(F$1:F1)+1,"-")

    and this can be copied down beyond your data to accommodate more data being added - the hyphens help to show where the formula is active. The formula identifies those records which match the options chosen, and allocates a unique sequential number to each.

    Then I have used this formula in A4 of Sheet2:

    =IFERROR(INDEX(Sheet1!A:A,MATCH(ROWS($1:1),Sheet1!$F:$F,0)),"")

    which returns data from column A of Sheet1. This can be copied across to column E, and then copied down as far as you like (I've copied to row 15 in this demonstration).

    As the data is now filtered, the sum of the Measure column is just:

    =SUM(D4:D15)

    though you might need to adjust the 15 if your formuale are copied further. I've put this formula in D2.


    So now you can just play about with the drop-downs in row 1, and see the display adjust accordingly.

    Hope this helps.

    Pete
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    10-24-2018
    Location
    Chicago,IL
    MS-Off Ver
    2007
    Posts
    42

    Re: How to index match a value based on multiple columns ?

    Thanks Pete!

+ 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. Using index match based on two match criteria in different columns
    By LearningByError in forum Excel General
    Replies: 2
    Last Post: 08-02-2018, 01:57 PM
  2. [SOLVED] Index match to sum multiple match columns
    By rosboy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-18-2018, 04:14 PM
  3. Match/Index Multiple Columns
    By fredlo2010 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 02-15-2018, 03:43 AM
  4. Replies: 4
    Last Post: 04-14-2017, 07:47 PM
  5. Index Match Based on Ratio of Two Columns
    By AK de FLA in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-25-2016, 09:36 PM
  6. INDEX MATCH MATCH multiple columns with same heading
    By djm198 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2016, 02:34 PM
  7. [SOLVED] INDEX and MATCH across multiple columns based on dropdown list
    By omni72 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-08-2012, 03:00 AM

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