Reputation: 759
This simple expression evaluates correctly at design time when attempting to set a variable value to the following expression:
@string(sub(int(variables('TargetRecordCount')), int(variables('SourceTotalRecordCount'))))
However when the pipeline is run, the following error occurs:
The function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type
I have verified that the issue is with the variable 'SourceTotalRecordCount'. The other variable is sourced from SQL table. The offending variable is obtained from the Lookup activity which references a CSV file.
The output of the Lookup activity is:
Setting the variable:
@activity('Lookup Source Total Record Count').output.value[0].SourceTotalRecordCount
The input of the SetVariable activity to define the variable TotalRecordDifference**emphasized text is:
I have used output.FirstRow.SourceTotalRecordCount but it still led to the same error.
Upvotes: 0
Views: 1525
Reputation: 5074
Your expression looks correct. I reproed your expression and was able to get the output without errors.
The issue might be with your incoming data. As per the error message, the variable value is invalid for int conversion.
You can debug by testing individual output values by converting them to int in your set variable. While storing the lookup output value into a variable, try to convert it to int there itself to identify the error.
Example:
@string(int(activity('SourceTotalRecordCount').output.value[0].SourceTotalRecordCount))
@string(int(activity('TargetRecordCount').output.value[0].TargetRecordCount))
Upvotes: 1