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

Set Variable Failure

The variable 'varCounter' of type 'Integer' cannot be initialized or updated with value of type 'String'. The variable 'varCounter' only supports values of types 'Integer'.

In here I am just trying to set up a simple counter. I have a column inside an excel file called "Counter", then im trying to set the variable "varCounter" but it seems it does not recognize the excel column as an int. I have tried to convert it to int, but an error telling "The expression is invalid" shows up. Does someone know how to bypass this?

 

MCeron98_0-1640661106869.png

MCeron98_1-1640661495688.png

 

 

Thanks a lot for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

Put the value coming from Excel inside a int() function and make sure it doesn't have any decimal places attached.  You also can't do varCounter + 1.  You need to use the Add() function in the expressions tab.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Pstork1
Dual Super User
Dual Super User

Put the value coming from Excel inside a int() function and make sure it doesn't have any decimal places attached.  You also can't do varCounter + 1.  You need to use the Add() function in the expressions tab.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi! Thanks a lot for your response! It was very useful. I tried to put the int() function but I feel im doing something wrong:

MCeron98_0-1640662463697.png

 

VictorIvanidze
Community Champion
Community Champion

VictorIvanidze_0-1640710565033.png

 

--------------------------------------------------------------------------------------
Contact me if you are interested in custom Power Automate development.

You need to add the int() function using the Expressions tab of the dynamic content dialog.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
NickyTemperley
New Member

Another solution would be to initialise a counter variable, type integer, and set it to one. Inside the 'apply to each' set the counter field to the counter variable as it is, then the last step of the 'apply to each' could be to increment the counter varaible. 'Increment variable' can be found under the variables tab in the connectors screen

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,736)