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
Super User

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
Super User

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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,306)