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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Split string if longer...
Power Automate
Unanswered

Split string if longer than x number of characters into new row/new file

(0) ShareShare
ReportReport
Posted on by

Hi Community!

 

Looking for some help, I have created a flow which takes a CSV file- removes nulls, unwanted columns and transposes the column I want into a row and saves as a txt file. The purpose of this is for users to easily be able to copy and paste specific information into our system from an email attachment.

 

So from this:

 

Column1, Column 2, Column 3

A              B                C

A              B                C

A              B                C

 

to this:

 

B,B,B

 

I'm wondering if there is a way to split the string after a certain number of characters e.g. 20 and either create a new row on the CSV or creates a new TXT file with the data.

 

Screenshot of how the data starts and ends up:

EG1.PNG

 

EG2.PNG

 

Best Wishes

 

Amy

Categories:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @Anonymous 

     

    You can check the length of a string with length() and potentially split with substring().  

     

    Are you trying to shorten the output from FinalString compose action? What is the desired output?

     

    Damien

  • Community Power Platform Member Profile Picture
    on at

    @DamoBird365  thanks for the advice!

     

    The desired output would be if the output in the FinalString compose action is longer than 255 characters it would split the string either onto a new row or a new txt file without cutting off a value.

     

    So just for ease an example if i wanted to split it if longer than 10 characters it would look like this:

     

    final string compose output: 1234,2345,3456,4567,5678

     

    Would go to (either new rows or new txt files):

    1234,2345,

    3456,4567,

    5678

     

    Many thanks for your help

     

    Amy

  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @Anonymous 

     

    My clever mate @Paulie78 came up with the following:

    DamoBird365_0-1629396123569.png

     

    Where from is:

    range(0, add(div(length(outputs('Compose')), 10), 1))
    and Map is:
    substring(outputs('Compose'), mul(item(), 10), if(greater(add(mul(item(), 10), 10), length(outputs('Compose'))), sub(length(outputs('Compose')), mul(item(), 10)), 10))
     
    Substring is based on starting position and length.  

    The clever bit is the IF statement to cater for the last substring.

     

    Oh, and I nearly forgot, you can then join() the array with a return line or however you please.

     

    Damien

  • Community Power Platform Member Profile Picture
    on at

    @DamoBird365 and @Paulie78  words can't describe my feelings towards you both right now! Thank you so much, I've been looking at split and substring for almost a solid week trying to figure it out. Thank you so much!!!

  • JvdSchelling Profile Picture
    18 on at

    Excellent stuff! Thanks. How would I go about if I want to chop up a long text string based on a more complex criterium: the last space prior to the maximum character count per line.

     

    Example: let's say I want to create individual text lines of 40 characters.

    Input: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

     

    Desired output: 

    Lorem ipsum dolor sit amet, consectetur
    adipiscing elit, sed do eiusmod tempor
    incididunt ut labore et dolore magna
    aliqua. 

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard