AZURE SYNAPSE - Compare two variables with function greater

Sisif0 1 Reputation point
2022-05-11T19:50:19.05+00:00

Hi everyone,

I have two lookup activities that are returning the number of records for two tables (Select Count(*) as Num_Rows From ...).
After each lookup activity I'm assigning the result to some variables defined like array type.

So far the previos step all looks fine, however when I try to compare both variables using an "If Condition" activity, the expression below is failing:

@Greater(variables('Source_NoRows')[0],variables('Target_NoRows')[0])

The error I receive is:

Error
{
"errorCode": "InvalidTemplate",
"message": "The function 'Greater' expects all of its parameters to be either integer or decimal numbers. Found invalid parameter types: 'Object'",
"failureType": "UserError",
"target": "If Condition1",
"details": ""
}

201147-pipeline.png

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.
4,364 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnnuKumari-MSFT 30,676 Reputation points Microsoft Employee
    2022-05-16T06:27:05.98+00:00

    Hi @Sisif0 ,
    Welcome to Microsoft Q&A platform and thankyou for posting your query.
    As I understand your question, you are trying to compare the rowcount of two tables in If block and trying to perform action accordingly in true and false blocks. Please let me know if my understanding is incorrect.

    Here, you are storing the output of lookup (rowcount of table) in variable which is not capable of holding integer value. Also, greater function only works with either integer or decimal.

    You don't need to introduce set variable activities here. You can directly compare the two lookup output in the If condition activity using the expression : @greater(activity('Lookup_Source_NoRows').output.count,activity('Lookup_Target_NoRows').output.count)

    Here is how your pipeline would look like: You can keep both the lookups in parallel as there is no dependency of one on another to wait.

    202134-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators