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 / how to trim whitespace...
Power Automate
Unanswered

how to trim whitespaces in PAD

(0) ShareShare
ReportReport
Posted on by 75

Hi ,

1. i am tying to trim whitespaces in the excel data within Power automate desktop as sometimes the user enters 1123c and sometimes by mistake 1123c folowed by space. 

2. In some case the data is AB_Package_1123 and some times it is IN_AB_package_1123. how to ensure both are read

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You can use Trim text to trim whitespaces from a text string. That should be straightforward. But if you want to fix it in Excel, you will either need to read every value individually and write it back to Excel, or use Find and replace in Excel spreadsheet and replace whitespaces (%" "%) with nothing (%""%), assuming that is valid for all of the cells.

     

    Not sure I understand the second question, though. What's wrong with it?

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @bensat2 

    In case if you want to trim the data during iteration of excel datatable you can directly apply trim end of the currentitem variable like below

    Deenuji_0-1712070297197.png

    Else as @Agnius mentioned you can use trim action which is available in the text package.

    Deenuji_1-1712070361509.png

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @bensat2 

     

    Please use the below code for the same:

    Deenuji_0-1712070723053.png

     

     

    Code:

    SET WebPageProperty3 TO $'''192.168.0.1'''
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Deenu\\Asset Details.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    LOOP FOREACH CurrentItem2 IN ExcelData
     IF WebPageProperty3 = CurrentItem2['IP'].Trimmed THEN
     Display.ShowMessageDialog.ShowMessage Title: $'''Info''' Message: $'''Trimmed''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
     END
    END

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at

    Hi @bensat2 ,

     

    If you have spaces at beginning and End of the string/input you can just use Trim Text Action directly as shown in below image 1:

     

    Image 1:

    VishnuReddy1997_0-1712122406540.png

     

    If you want to remove spaces in between the text and start and end of text/input/string you can use the VBScript as shown in below image.

    Please find the solution.

    VishnuReddy1997_1-1712122521734.png

     

    Code:

    SET UserInput TO $'''IN_AB_ package_ 1123'''
    @@copilotGeneratedAction: 'False'
    Scripting.RunVBScript.RunVBScript VBScriptCode: $'''Dim str
    str = \"%UserInput%\"
    Set re = New RegExp
    re.Pattern = \"\\s+\"
    re.Global = True
    str = Trim(re.Replace(str, \"\"))
    WScript.Echo str''' ScriptOutput=> VBScriptOutput ScriptError=> ScriptError
    
    

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

     

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard