Ask a questionAsk a question
 

AnswerConditional lookup

  • Tuesday, November 03, 2009 10:30 PMjschroeder Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am using a lookup task to find values for a sales order table.  The flat file I'm reading in may or may not contain a value for "customer contact".  if the value is in the file, i need to use it.  If not, I need to look it up in the customer table.  Can I perform this logic using a lookup task only, or do I need to do somethinglike a conditinal split and then do two separate lookups?
    John Schroeder

Answers

  • Wednesday, November 04, 2009 4:15 PMSudeep Raj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Nitesh is correct.
    No need to use the conditional split. Directly do the lookup and you get the records which match.

    Another approach could be done as you said you have lot of lookups to be performed.
    first dump the data from the text file to a staging table.
    Use this table as the source and modify the source query by using joins to get the other column values.
    This way you do not need to use the lookup task.
    Hope this helps !!
    Sudeep   |    My Blog
    • Marked As Answer byjschroeder Thursday, November 05, 2009 4:11 PM
    •  

All Replies

  • Wednesday, November 04, 2009 1:28 AMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    What do you mean by "If the value is in file"?
    Please give some sample data


    Nitesh Rai- Please mark the post as answered if it answers your question
  • Wednesday, November 04, 2009 2:34 AMETL vs ELTL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    here you can use a conditional split on customer contact.
    add an expression in conditional split as  (trim([customer contact])=="" || ISNULL(customer contact))

                                                                       |
                                                       ----------------------
                                                       |   conditional split   |
                                                       -----------------------
                                                               |                |
                                                            true             Default
                                                               |                |
                                                         lookup            file customer contact
                                                    customer contact




    if the above condition is true then use a lookup on customer table else ... :)

    Thanks-

    Let us TRY this | Don’t forget to mark the post(s) that answered your question
    • Unproposed As Answer byjschroeder Wednesday, November 04, 2009 3:12 PM
    • Proposed As Answer byBharani 3010 Wednesday, November 04, 2009 4:07 AM
    •  
  • Wednesday, November 04, 2009 3:11 PMjschroeder Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks for your response.  Now let's say the problem is much more complicated and the import file contains dozens of fields that may or may not have a value and may or may not need a lookup.  What I see with this type of solution is a very complicated tree that branches out to include all possibilities of empty and non-empty values.  Is there a way to accomplish the import without using the conditional split method you suggest above?


    John Schroeder
  • Wednesday, November 04, 2009 3:40 PMNitesh Rai Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Why dont you directly use a lookup without a conditional split?
    Any value (columns comming from source) that is null or blank will fail the lookup and will be redirected to a different path.
    After this you can use the redirected rows and perform whatever opeartion is required.

    Nitesh Rai- Please mark the post as answered if it answers your question
  • Wednesday, November 04, 2009 4:15 PMSudeep Raj Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Nitesh is correct.
    No need to use the conditional split. Directly do the lookup and you get the records which match.

    Another approach could be done as you said you have lot of lookups to be performed.
    first dump the data from the text file to a staging table.
    Use this table as the source and modify the source query by using joins to get the other column values.
    This way you do not need to use the lookup task.
    Hope this helps !!
    Sudeep   |    My Blog
    • Marked As Answer byjschroeder Thursday, November 05, 2009 4:11 PM
    •  
  • Thursday, November 05, 2009 4:11 PMjschroeder Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks for your responses.  Due to the complexities of my problem, neither the conditional split or the direct lookup method will work.  I need to use Sudeep's suggestion of dumping the data to a staging table.


    John Schroeder