Synapse Dataflow Lookup for multiple conditions with OR

Edward Coltman 20 Reputation points
2025-04-14T15:40:29.08+00:00

I am building a pipeline in Azure Synapse. Within one of my dataflows I am introducing a lookup function. I am using two key names to perform the lookup. The json field looks a bit like this:

... lookup(Source@incoming_name_a == target_name_a",
                "     && Source@incoming_name_b == target_name_b,",
                "     multiple: false,",
                "     pickup: 'any',",
                "     broadcast: 'auto')~> LookupNames", ...

I need to adjust this such that the lookup will match on either name_a OR name_b.
Which could look like this:

"... lookup(Source@incoming_name_a == target_name_a",
    "     || Source@incoming_name_b == target_name_b,",

This should be simple, but there are no options for adding this logic between the multiple conditions in the lookup dataflow activity. How can I do this? I have tried to directly edit the json and the dataflow script, but these changes are not being accepted.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,378 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 34,666 Reputation points MVP Volunteer Moderator
    2025-04-14T17:01:16.3133333+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    In synapse data flows (also known as mapping data flows), the lookup transformation only supports AND (&&) conditions between match keys, it does not support OR (||) logic directly.

    This limitation means your attempted JSON/script update with || will not be accepted or function as expected. You cannot do a logical OR across match conditions within a single Lookup transformation

    Approach 1: Use Two Lookups and Union

    1. Create two separate Lookup transformations:
      • One that joins on incoming_name_a == target_name_a
      • Another that joins on incoming_name_b == target_name_b
    2. Use a Union transformation to combine the outputs of the two Lookups.
    3. Optionally add a Derived Column or Conditional Split if you need to de-duplicate or add metadata about which match condition was met.

    Approach 2: Prejoin Using Derived Columns

    If you want to avoid two lookups, another method is:

    1. Create a Derived Column that combines the 2incoming names into a single field with a known priority or structure.

    Use this derived field as a single match key in your Lookup.

    But this only works if the match logic can be standardized (a coalesce or priority-based name selection)

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.