Do an offset VLOOKUP

Last updated on 14/04/2024
Reading time : 3 minutes

This article will explain how to construct an offset VLOOKUP. That is, how to return values ​​that are not on the same line as the desired value.

Problem to solve

In case you have a table that contains identifiers common to several rows, or empty cells to indicate that the identifier is repeated, it is strongly recommended to re-order your data.

How to transfer vertical data into an ordered table

To achieve this, we will use 3 functions, INDEX, MATCH and OFFSET

We have a table (column A:D) which lists the sales of our items at the end of each month. To improve readability, we want to reorder our values ​​in the 2 tables in columns G to J to display the sales and turnover per month.

As you can see, in column A, many dates are missing. But that is not the problem. Even if we copy the dates into the empty cells, we are facing the same problem; we cannot identify the data for items B, C and D

Solution with Power Query

The method described below applied when Power Query did not exist. From, without the slightest formula, You can get the same result just in a few steps

Rotated columns in Excel sheet

Construction of the formula

The idea is to find the position of the dates (which is our identifier) ​​and read the data below by shifting 1, 2 or 3 lines.

Ne pas use the VLOOKUP function

Indeed, the VLOOKUP function is perfect for retrieving values ​​that are on the same line as the identifier.

But for the other lines it is impossible because the VLOOKUP function returns a value and not a range.

Prefer the INDEX function

We must then base ourselves on the function INDEX to build our research because the INDEX function returns a range of data.

For formula G2, we will write the following formula to return the number of items sold in January 2014 for product A. For the detailed explanations about the INDEX function, you can consult INDEX function and to the MATCH function.

Recherche_decalee_2

=INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$49,0),3)

The function can be understood as follows:

  • We are interested in the data range A2:D49 (our data without the header line)
  • We search for the line corresponding to the date that interests us (EQUIV function).
  • After we indicate that we retrieve the data from the 3rd column (parameter 3) to return the number of items sold.
Recherche_decalee_3

If we want to return the turnover, we specify 4 for the last parameter of the INDEX function.

=INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$49,0),4)

Do an offbeat search

As the INDEX function returns a range of data (and not a value as the VLOOKUP function does), we will be able to include the 2 previous formulas in a SHIFT function.

=OFFSET(pivot cell reference, number of rows, number of columns)

The OFFSET function returns data relative to a pivot cell.

In our example, to return the number of articles B, we must shift one cell down from the previous search. We will therefore write our final formula as follows for product B:

=DECALER(INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$46,0),3),1,0)

Recherche_decalee_4

And by copying this formula, the final result is:

Comment

  1. Francis Molina
    22/02/2021 @ 12:36 p.m.

    Bravo for the quality of the explanations.
    Let me ask you a question.
    I have two columns A& B concatenated in a column DD, I perform the following search in an independent cell of type: =search(9^9;DD15:DD400). Formula that works very well in other formats. but I cannot display the values.
    The lines in the search column contain this formula: =IF(A17="";"";CONCATENATE(ROUNDED(A17/10;0);"/";ROUNDED(B17/10;0))).
    For example colA =117 Col =B68 and col DD/ 12/7. Result in the cell
    #N / A. I varied the formats without results. Being retired, I do this for the pleasure of exercising my mind but I would like to understand why it doesn't work.
    Thank you in advance for any insight you can give me.
    Regards

    Francis

    Reply

Leave comments

Your email address will not be published. Required fields are marked with *

This site uses Akismet to reduce unwanted. Learn more about how your feedback data is processed.

Microsoft MVP 2024

Newsletter

Once a month:
Tips and quizzes

    We won't spam you. You can unsubscribe at any time.

    Do an offset VLOOKUP

    Reading time: 3 minutes
    Last updated on 14/04/2024

    This article will explain how to construct an offset VLOOKUP. That is, how to return values ​​that are not on the same line as the desired value.

    Problem to solve

    In case you have a table that contains identifiers common to several rows, or empty cells to indicate that the identifier is repeated, it is strongly recommended to re-order your data.

    How to transfer vertical data into an ordered table

    To achieve this, we will use 3 functions, INDEX, MATCH and OFFSET

    We have a table (column A:D) which lists the sales of our items at the end of each month. To improve readability, we want to reorder our values ​​in the 2 tables in columns G to J to display the sales and turnover per month.

    As you can see, in column A, many dates are missing. But that is not the problem. Even if we copy the dates into the empty cells, we are facing the same problem; we cannot identify the data for items B, C and D

    Solution with Power Query

    The method described below applied when Power Query did not exist. From, without the slightest formula, You can get the same result just in a few steps

    Rotated columns in Excel sheet

    Construction of the formula

    The idea is to find the position of the dates (which is our identifier) ​​and read the data below by shifting 1, 2 or 3 lines.

    Ne pas use the VLOOKUP function

    Indeed, the VLOOKUP function is perfect for retrieving values ​​that are on the same line as the identifier.

    But for the other lines it is impossible because the VLOOKUP function returns a value and not a range.

    Prefer the INDEX function

    We must then base ourselves on the function INDEX to build our research because the INDEX function returns a range of data.

    For formula G2, we will write the following formula to return the number of items sold in January 2014 for product A. For the detailed explanations about the INDEX function, you can consult INDEX function and to the MATCH function.

    Recherche_decalee_2

    =INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$49,0),3)

    The function can be understood as follows:

    • We are interested in the data range A2:D49 (our data without the header line)
    • We search for the line corresponding to the date that interests us (EQUIV function).
    • After we indicate that we retrieve the data from the 3rd column (parameter 3) to return the number of items sold.
    Recherche_decalee_3

    If we want to return the turnover, we specify 4 for the last parameter of the INDEX function.

    =INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$49,0),4)

    Do an offbeat search

    As the INDEX function returns a range of data (and not a value as the VLOOKUP function does), we will be able to include the 2 previous formulas in a SHIFT function.

    =OFFSET(pivot cell reference, number of rows, number of columns)

    The OFFSET function returns data relative to a pivot cell.

    In our example, to return the number of articles B, we must shift one cell down from the previous search. We will therefore write our final formula as follows for product B:

    =DECALER(INDEX($A$2:$D$49,EQUIV($F2,$A$2:$A$46,0),3),1,0)

    Recherche_decalee_4

    And by copying this formula, the final result is:

    Newsletter

    Once a month:
    Tips and quizzes

      We won't spam you. You can unsubscribe at any time.

      Comment

      1. Francis Molina
        22/02/2021 @ 12:36 p.m.

        Bravo for the quality of the explanations.
        Let me ask you a question.
        I have two columns A& B concatenated in a column DD, I perform the following search in an independent cell of type: =search(9^9;DD15:DD400). Formula that works very well in other formats. but I cannot display the values.
        The lines in the search column contain this formula: =IF(A17="";"";CONCATENATE(ROUNDED(A17/10;0);"/";ROUNDED(B17/10;0))).
        For example colA =117 Col =B68 and col DD/ 12/7. Result in the cell
        #N / A. I varied the formats without results. Being retired, I do this for the pleasure of exercising my mind but I would like to understand why it doesn't work.
        Thank you in advance for any insight you can give me.
        Regards

        Francis

        Reply

      Leave comments

      Your email address will not be published. Required fields are marked with *

      This site uses Akismet to reduce unwanted. Learn more about how your feedback data is processed.