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 / Help with trim text fr...
Power Automate
Answered

Help with trim text from DataTable

(0) ShareShare
ReportReport
Posted on by 19

Hi,

 

I have a table that comes from Excel. There´s an previous action cleaning it up and the result looks like this.

karl86_0-1688808467721.png

 

I have to make sure that the text in the column [Description] is less than 50 characters.
How do i solve this in the easiest way? I tried for each loop but have a hard time getting that specific column and is new on PDA.
In e.g. Blue Prism that i have worked with earlier, i would have looped the collection/array and defined that column and made sure len is <50 char but i can´t find the same kind of function so easily here.

 

Thanks in advance!

Best regards,
Karl

I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @karl86 

     

    See this example 

     

    Nived_Nambiar_0-1688812641964.png

     

    First action creates a datatable variable with some values (for demo purposes)

     

    Now next i am using loop to loop through that datatable by numbers of times equal to that of rows present in datatable, and in the loop scope, i will use get subtext to get specific text from beginning, in my case, i have made the action to retrieve the first 4 characters from A column and then update the row value, the updating row value is done via set variable action.

     

    see below for more details 

    Nived_Nambiar_1-1688812876095.png

     

    Nived_Nambiar_2-1688812887782.png

     

     

    By this, datatable will have A column with 4 characters data.

     

    Nived_Nambiar_3-1688812918008.png

     

     

    Hope this helps !

    Mark it as solution if it resolves your query !

     

  • karl86 Profile Picture
    19 on at

    Thank you Nived for taking your time. I will try this latest by tomorrow evening and mark with ´Accept as Solution´ if it does the job. Thanks once again and have a great day.

  • karl86 Profile Picture
    19 on at

    Hi @Nived_Nambiar 

     

    I can retrieve the text as intended but i have 2 questions.
    Like in my example the maximum 50 characters is allowed but the text usually is less than 20 characters if i use 50 as in example below, i get an error message. I need to check the length first och allow it to pass on if it´s <50 chars and only pass the argument if it´s above 50 characters.

    Secondly, i don´t know beforehand how many rows my DataTable contains. Could you please elaborate on your LoopIndex critera below so it actually matches the amount . Shouldn´t i use foreach loop instead? 

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You can use the .Length property of a text variable to check its length. So, if you use %[dt1][LoopIndex['A']% to get the text, you can do an IF condition to check if %[dt1][LoopIndex['A'].Length% is greater than 50, and if it is - then use the Get subtext action. Otherwise - leave it as it is.

     

    As for the LoopIndex, a data table variable has a .RowsCount property, which @Nived_Nambiar used correctly. It holds the number of rows in the data table. But since indexes are 0-based, what Nived suggested was looping from 0 to RowsCount-1. This is correct and it works better than using a For each loop in your case, because with a For each you would not have an index that is necessary to write back to the data table. If you have no intention on modifying the data table, For each is perfectly fine (and easier to use). But if you want to modify the table, indexes are necessary and then using a simple Loop like the one Nived suggested is a better idea.

     

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

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • karl86 Profile Picture
    19 on at

    Thank you for the clarification. @Nived_Nambiar  Now marked as ´Accept as Solution´ Huge thanks guys!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 247 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 164 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 138 Super User 2026 Season 2

Last 30 days Overall leaderboard