cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Glebenerd
Level: Powered On

Convert text to number

Greetings:

 

I am using an MS Forms form to trigger an MS Flow which will transfer the input into a new list item in sharepoint.  Even though MS Forms allows you to specify that a field has to be a number, it seems to pass to flow as a text.  Is there a way to convert the text into a number in a number field? 

 

Thank you

 

John

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Convert text to number

Hi @Glebenerd,

 

Yes, there is a way to convert it into Number in Microsoft Flow.

An easy way for you to manage,

1. Add one compose Action, choose the field (Dynamic content from the form actions) that you would like to convert as the Compose Input, 

2. Add another Compose Action, under the Input, copy and paste the following:

"@int(outputs('Compose'))"      //for integer

Or

"@float(outputs('Compose'))"   // for floating-point number

Function reference: WorkFlow Definition Language.

3. Then use the Dynamic outputs of Compose 2 for the atcual field.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Community Support Team
Community Support Team

Re: Convert text to number

Hi @Glebenerd,

 

Yes, there is a way to convert it into Number in Microsoft Flow.

An easy way for you to manage,

1. Add one compose Action, choose the field (Dynamic content from the form actions) that you would like to convert as the Compose Input, 

2. Add another Compose Action, under the Input, copy and paste the following:

"@int(outputs('Compose'))"      //for integer

Or

"@float(outputs('Compose'))"   // for floating-point number

Function reference: WorkFlow Definition Language.

3. Then use the Dynamic outputs of Compose 2 for the atcual field.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Glebenerd
Level: Powered On

Re: Convert text to number

Thank you:

 

That answer opened up a world possibilities,  I had no idea that compose allowed you to reach into the workflow language.

 

John

hassaanahmad
Level: Powered On

Re: Convert text to number

Michael,

Thanks for your solution. Unfortunately, I wasn't able to get the Flow to work for me. With the two (2) compose functions, I attemped to convert my 'Total Cost' value from a string to an integer per your instructions. However, when I use the dynamic output of Compose 2 (i.e., this is  the compose titled 'Total Cost' for me) in a 'greater than or equal to' function, I get an error. See the screenshots below. I'd greatly appreciate your help. Thank you.

1.png

 

 

 

2.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

hassaanahmad
Level: Powered On

Re: Convert text to number

I figured it out. I used the 'float' conversion function: 

float(triggerBody()?['Total_x0020_Cost'])
 
Thanks anyway.
LMeister
Level: Power Up

Re: Convert text to number

Another possible way to convert string to int:

first initialize a empty string variable at the start of the flow using the intialize variable, in my case i named it 'deletionID'.

Then add in the text you want using the set variable function down in the flow

Then you can use the compose with the input as "@int(variables('deletionID'))". The output from the compose will be an int value.

What variables does is that it takes in the name of any variable and gives you the value of the variable. Int function will only take in a value so the output of variables sits nicely in the formula

Just wanted to share this as an alternative if error occurs when there are multiple compose needed in parallel branch
ilu989
Level: Powered On

Re: Convert text to number

Hi @v-micsh-msft ,

 

Can you please tell me how to convert the integer to be the string? Ex: 123 converts to "123"

Because I just use the "Select" action to make my data like this:

string capture.JPG

But I need to use "0" to be the unique key for filter array, but filter array can't recognize the integer content, so I need to convert to be the string, how can I get this? I already try String(item()[0]) in Select action, but not workable.

 

Please give me any advice.

Regards,

ilu989

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 345 members 6,035 guests
Please welcome our newest community members: