question

Sisif0 avatar image
0 Votes"
Sisif0 asked AnnuKumari-MSFT edited

AZURE SYNAPSE - Compare two variables with function greater

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
pipeline.png (16.0 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

How have you set the variables? (PS these aren't required)

Are you doing "First Row Only" in your lookups? If not, then I suspect you need to have something like
variables('Source_NoRows')[0].Num_Rows


But if doing "First Row Only" then I would guess
variables('Source_NoRows').firstRow.Num_Rows

0 Votes 0 ·

Hi @RyanAbbey-0701

First at all I used "FirstRow" option, currently not.

For me it's a little bit confusing because when I create the variable at a Pipeline level, I just can choose between three types: String, Array or Boolean. The values that I want to store in my two variables are numericals but sometimes higher than 100.000.000 probably I will have to multiply that value by 10 or 100. I decided to use Array variables, just for testing it.

Inside IFConfition activity I only want to check if one variable is higher than the other, no more. You know:

if(var1 > var2){
do this
}
else{
do that
}

Can you give me a hand?

Thanks

0 Votes 0 ·

Hi @Sisif0 ,
Just following up to see if the below answer helped. Please do consider clicking Accept Answer and Up-Vote for the same as accepted answers help community as well. If you have any further query do let us know.

0 Votes 0 ·

1 Answer

AnnuKumari-MSFT avatar image
0 Votes"
AnnuKumari-MSFT answered AnnuKumari-MSFT commented

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



image.png (40.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Sisif0 ,
Just checking in to see if the above answer helped. Please do consider clicking Accept Answer and Up-Vote for the same as accepted answers help community as well. If you have any further query do let us know.

0 Votes 0 ·