+ Reply to Thread
Results 1 to 6 of 6

Return a value based on 2 variables in one column.

  1. #1
    Forum Contributor
    Join Date
    08-13-2009
    Location
    Caribbean
    MS-Off Ver
    Excel 2003
    Posts
    129

    Return a value based on 2 variables in one column.

    Hello all,

    What I need:

    A formula in column G that
    1) looks at column M (column M has two variables "BX" and "GL")
    2) if column M says "BX" then return a lookup on column A (the lookup value appears twice in column A, once for "BX" and once for "GL") and return the date listed in column F that corresponds with the lookup value for "GL"
    3) And the other way around... if column G says "GL" then lookup the value in column A and return the corresponding date in column F for "BX"

    In summation:

    Column A has the lookup value. The lookup value can appear more than once in column A.
    Column G is the empty column that needs a value returned to it.
    Column M has two variables that drive the formula... "BX" and "GL"
    Column F has the date that needs to be returned to column G.

    Some background:

    I have developed a pivot table reconciliation. It combines two records of data (identified by column M GL/BX). The unique identifier, the lookup value, can appear (should appear) more than once in column A. I need a formula that will return the date in which the record appears in the BX dataset to correspond to the GL data.

    FOr example, if "ABC" was booked in the BX on Jun15, and "ABC" was booked in the GL on Jul15 then:
    A...............F.............G........................................................M
    ABC...........Jun15........Jul15 (returned by formula).....................BX
    ABC...........Jul15.........Jun15(returned by formula)......................GL


    thanking you in advance, please let me know if you need me to clarify anything furhter.

    Best
    M
    Last edited by mysticmoron109; 11-03-2015 at 12:58 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Return a value based on 2 variables in one column.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Return a value based on 2 variables in one column.

    Try in G1:

    =IFERROR(LOOKUP(2,1/(($A:$A=A1)*($M:$M<>M1)),$F:$F),"")
    Quang PT

  4. #4
    Forum Contributor
    Join Date
    08-13-2009
    Location
    Caribbean
    MS-Off Ver
    Excel 2003
    Posts
    129

    Re: Return a value based on 2 variables in one column.

    Quote Originally Posted by bebo021999 View Post
    Try in G1:

    =IFERROR(LOOKUP(2,1/(($A:$A=A1)*($M:$M<>M1)),$F:$F),"")
    edited to troubleshoot. will post results. any other ideas?
    Last edited by mysticmoron109; 11-03-2015 at 09:59 AM.

  5. #5
    Forum Contributor
    Join Date
    08-13-2009
    Location
    Caribbean
    MS-Off Ver
    Excel 2003
    Posts
    129

    Re: Return a value based on 2 variables in one column.

    =IFERROR(LOOKUP(2,1/(($A:$A=A6)*($P:$P<>$P6)),$D:$D),"")

    that is the formula that i ended up using and it works very well.

    However, it is extremely slow and almost crashes the workbook. any idea why? or is there any other formula that can make this more efficient? perhaps make this an index/match formula?

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Return a value based on 2 variables in one column.

    Try to avoid using entire range reference like A:A, limit to actual size, i.e A1:A100.

+ 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. Code To Look In Multiple Sheets Return Value Based On Row and Column Variables
    By ZooTV92 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2015, 01:19 PM
  2. Formula to Return a Value based on 2 Variables
    By Howdoesitwork in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-30-2015, 12:42 PM
  3. Return a value based upon two variables
    By liquidtrails in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-04-2014, 09:11 PM
  4. Return a value based on two variables
    By celphtitled in forum Excel General
    Replies: 5
    Last Post: 04-20-2014, 04:48 PM
  5. Return a vaule based on Multiple variables
    By cooperman82 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-04-2012, 06:50 AM
  6. Excel 2007 : Return all values based on 2 variables
    By Aggie81 in forum Excel General
    Replies: 3
    Last Post: 07-26-2010, 11:34 PM
  7. Return a date based on 2 variables.
    By Mishka1 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-21-2007, 06:56 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