web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert Split function...
Power Automate
Answered

Convert Split function output into integer

(0) ShareShare
ReportReport
Posted on by 43

In my flow, I pull data from a .tsv file we host, then split it into rows and then grab the headers from the first line and it all works fine.

 

The problem I have it trying to convert 2 of the values from String to Integer. The value should be a price so 1000.00 for example.

 

jamielakes_0-1674224993814.png

 

I get the value from the .tsv using the expression: split(item(),' ')?[4] 

 

This works and pulls it as a string. I've tried many ways to convert this into a integer but nothing seems to be working. The most obvious way to me is int(split(item(),' ')?[4]) but this doesn't work.  

 

This is the error I get: The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

 

Any help would be appreciated. 🙂

Categories:
I have the same question (0)
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Can you show the exact output you get from using your expression:

    split(item(),' ')?[4] 

     

    If it contains a decimal place, then you may need to convert it to a float instead of an int.

  • jamielakes Profile Picture
    43 on at

    The output is a price, so 1234.00 for eg. There is a decimal... what expression would convert my current one to a float?

  • grantjenkins Profile Picture
    11,063 Moderator on at

    You can try:

     

    float(split(item(),' ')?[4])

     

    You would think that converting to int would just truncate the decimal part, but it fails instead.

  • jamielakes Profile Picture
    43 on at

    @grantjenkins 

     

    this is the error I get: The template language function 'float' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    Do any of your rows of data not have a value entered for this field (blank fields)? If so, what would you want to do with these? Ignore them, or default to 0.00?

     

    Are you able to ensure the values being returned are strings "1234.00", not just 1234.00

     

    See some examples below with regards to converting to int or float.

     

    //Convert string with decimal places to float
    float('1234.00')
    
    //Convert string with decimal places to integer (will round appropriately)
    //Note that N0 means a Number with 0 decimal places
    int(formatNumber(float('1234.00'), 'N0'))
    
    //Convert string with no decimal places to integer
    int('1234')
    
    //Default to 0 if object doesn't contain the value we want, or it's set to null, and convert to integer
    int(coalesce(outputs('Data')?['Number'], '0'))
    
    //Default to 0.00 if object doesn't contain the value we want, or it's set to null, and convert to float
    float(coalesce(outputs('Data')?['Number'], '0.00'))

     

     

  • jamielakes Profile Picture
    43 on at

    @grantjenkins, amazing!

     

    Where did you find those examples? I searched for hours and couldn't find  anything remotely close to either of the bottom 2...

     

    Here's what worked for me:

     

    float(coalesce(split(item(),'	')?[4], '0.00'))

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard