cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Template add function expect its first parament to be integer or a decimal number, while the provided value is of type string; how to solve

Looking for assistance/quidance for the following error message to solve it

 

Unable to process template language expressions in action 'Set_variable' inputs at line '1' and column '2223': 'The template language function 'add' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#add for usage details.'.

 

Thanks and best regards

Arthur

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hello @arthcras

You will have to convert the string number to a integer or a float depending on if it’s whole number or a decimal. To do this:

Add a compose action,
Inside the compose, use the expression int() or float() depending on if it’s whole number or decimal.
Inside the ( ) put the dynamic content of the string number (this is the first parameter)

Now inside your set variable reference the compose for the first parameter.

Basically wherever you are getting this value from, is not a number to start. It’s type string. Meaning the original value might be “2” and you need it to be 2 without quotes. Quotes makes the code think it’s a string.




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips, tricks, and guides
FlowAltDelete




View solution in original post

4 REPLIES 4
Super User III
Super User III

Hello @arthcras

You will have to convert the string number to a integer or a float depending on if it’s whole number or a decimal. To do this:

Add a compose action,
Inside the compose, use the expression int() or float() depending on if it’s whole number or decimal.
Inside the ( ) put the dynamic content of the string number (this is the first parameter)

Now inside your set variable reference the compose for the first parameter.

Basically wherever you are getting this value from, is not a number to start. It’s type string. Meaning the original value might be “2” and you need it to be 2 without quotes. Quotes makes the code think it’s a string.




Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips, tricks, and guides
FlowAltDelete




View solution in original post

Frequent Visitor

Thanks for the reply

The begin situation is as follows

 

1 Manual trigger a flow

2. Get items (sharepoint)

3 Initialize variable (set on float)

4. Apply to each (set variable) 

 

formule

add(items('Apply_to_each') ['GrossRiskS'], variables ('TotalAverageGrossScore'))

 

where do i have to put the compose action

Hello @arthcras 

 

Since you gave me your expression, we can try and simplify it by using the expression directly.

Try one of these:

If your GrossRiskS value is an Integer or a whole number use:

 

add(int(items('Apply_to_each') ['GrossRiskS']), variables ('TotalAverageGrossScore'))

 

 

If the value is a decimal use:

 

add(float(items('Apply_to_each') ['GrossRiskS']), variables ('TotalAverageGrossScore'))

 

 

 

Let me know if there are any errors.





Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips, tricks, and guides
FlowAltDelete




Frequent Visitor

Hello

This issue solved on the way as you suggested

Thank you

best regards

Arthur

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (7,853)