+ Reply to Thread
Results 1 to 6 of 6

INDEX/MATCH with moving data and 2 column headers

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2021
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    3

    INDEX/MATCH with moving data and 2 column headers

    Okay, I did a quick search on the forum in order to confirm wether someone had met the same problem or not, but didn't find anything.

    So basically, the problem here is down to the proper use of INDEX/MATCH, but to give some backstory, here is my problem: I'm trying, through excel, to achieve results that were previously done by SQL requests on a database. I understand that, without VBA, I migh be asking too much. To make long story short, it was previously possible to extract any and all data from the database, but for the time being, I'm stuck with extractions generated in a way I cannot modify.

    As you will see in the attached file, I'm working on expenses and profits, trying to compare different fiscal years. All accounts, may they be on the expense side (beginning with 6) or the profits side (beginning with 7), are always listed in the same B column. But depending on the structure I work on, it might not use the whole array of account. And if an account is not used, it is not simply filled with 0, it will rather not appear.

    Same goes for the activity columns: in the attached example, there are only 2, COMM and OPS. But you could have much more, it all depends on the way the structure decided allocate its accounts. Again, it's the same mechanic used for the accounts: if an activity code is not used, it does not appear. This means that a code like OPS, which is always used, will always see its location within the spreadsheet change depending on the structure. As you can see, under an activity code, there are always the same 4 subcolumns, and thus, the activity code cell is a merged one.

    In the end, what I'm looking for is Cell C3 in 'Analysis'!: a way to INDEX/MATCH a data with an evolving line, where I only take the "prefix" of the account, and an evolving column, with 2 headers.
    INDEX/MATCH with 2 MATCH conditions seemed the way to go, but I might be wrong from the beginning.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,779

    Re: INDEX/MATCH with moving data and 2 column headers

    in C3

    =INDEX('Data 2020'!$B$3:$I$17,MATCH("6 / *",'Data 2020'!$A$3:$A$22,0),MATCH("COMM",'Data 2020'!$B$1:$I$1,0)+MATCH("Expenses (made)",'Data 2020'!$B$2:$I$2)-1)

    in C4

    =INDEX('Data 2020'!$B$3:$I$17,MATCH("6 / *",'Data 2020'!$A$3:$A$22,0),MATCH("OPS",'Data 2020'!$B$1:$I$1,0)+MATCH("Expenses (made)",'Data 2020'!$B$2:$I$2)-1)

  3. #3
    Registered User
    Join Date
    05-18-2021
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    3

    Re: INDEX/MATCH with moving data and 2 column headers

    Hello John,

    Thank you for your answer, works fine ! If I understand correctly, the 2 MATCH had to be linked with a + and not a *. I didn't know a * could replace a LEFT, nice catch. Btw, why did you add -1 at the end ?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,779

    Re: INDEX/MATCH with moving data and 2 column headers

    =INDEX('Data 2020'!$B$3:$I$17,MATCH("6 / *",'Data 2020'!$A$3:$A$22,0),MATCH("COMM",'Data 2020'!$B$1:$I$1,0)+MATCH("Expenses (made)",'Data 2020'!$B$2:$I$2)-1)

    The first MATCH (in RED) will return 1 (matches column B which is the first in the "lookup" range $B$1:$I$1: the second MATCH (BOLD) will return 2 as we match on column C so 1+2 =3 but we want column C (which is second column in range $B$2:$I$2) so we subtract 1.

    Hope this helps.

  5. #5
    Registered User
    Join Date
    05-18-2021
    Location
    Europe
    MS-Off Ver
    2013
    Posts
    3

    Re: INDEX/MATCH with moving data and 2 column headers

    Indeed, that helps a lot, thank you ! Which means I must adjust that last number depending on which subcolumn I'm looking for, right ?

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,779

    Re: INDEX/MATCH with moving data and 2 column headers

    Yes because you are first finding "COMM" or "OPS" and same column (next line down) is also the first sub-category.
    Last edited by JohnTopley; 05-18-2021 at 10:31 AM.

+ 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. [SOLVED] find row header based on table and column headers reverse lookup index & match
    By jnsorrera in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-18-2020, 02:08 AM
  2. Index/Match with repeating column headers
    By novazona in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-04-2018, 12:12 PM
  3. Index one column off an area of match (but no headers)
    By Parmx in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-18-2018, 02:12 AM
  4. [SOLVED] Lookup (index/match) and return column headers
    By Barslund in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-08-2017, 06:01 AM
  5. Multiple headers when data is the same on a Index Match!!
    By Acousticlife81 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-05-2017, 01:25 PM
  6. Replies: 1
    Last Post: 01-07-2015, 09:20 AM
  7. Moving Data with Index & Match for Pricing Sheet
    By Cameron12 in forum Excel General
    Replies: 9
    Last Post: 07-25-2012, 07:23 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