cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
arthcras
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
Jcook
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
Jcook
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

arthcras
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





arthcras
Frequent Visitor

Hello

This issue solved on the way as you suggested

Thank you

best regards

Arthur

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (53,794)