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 / How to Build a String ...
Power Automate
Answered

How to Build a String in Power Automate Desktop.

(0) ShareShare
ReportReport
Posted on by 9

| ListName | Code | Notes |
|----------  |-------|-------  |
| 1              | ABC  | Hello   |
| 2              | Asd   | Hi       |

i have a Excel File Like this,
i want to Build a String Dynamically Like this
" When ListName = '1' then Code = 'Hello'
  When ListName = '2' then Code = 'Hi' "

The number rows might increase or might not increase i want My PAD bot to read the Excel file and Based on the Data inside the file. i want to Build a String like above.

How can i achieve it in Power automate desktop.

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I am not exactly sure I understand you correctly, but I assume you want a single multi-line string created from all the rows in your Excel file. If that assumption is correct, a flow like this can do it:

    Agnius_0-1689245268381.png

    The idea is that you need to open Excel, read the data, then close Excel and loop through the items you retrieved. 

    For each row in the table, you set the string value and add it to a list. Once the loop is done, you join the list using a new line as the delimiter.

    This will result in the %JoinedText% variable looking like this at the end:

    Agnius_1-1689245350854.png

     

    Here's a code snippet for the entire flow if you want to copy and paste it into your PAD designer to have the same actions created automatically for you:

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\RPA\\Strings.xlsx''' Visible: False ReadOnly: False Instance=> ExcelInstance
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    Excel.CloseExcel.Close Instance: ExcelInstance
    Variables.CreateNewList List=> List
    LOOP FOREACH CurrentItem IN ExcelData
     SET String TO $'''When ListName = \'%CurrentItem['ListName']%\' then Code = \'%CurrentItem['Notes']%\''''
     Variables.AddItemToList Item: String List: List
    END
    Text.JoinText.JoinWithDelimiter List: List StandardDelimiter: Text.StandardDelimiter.NewLine DelimiterTimes: 1 Result=> JoinedText

    Note: you will need to change the path to the file in the Launch Excel action so that it leads to the actual file you want to read.

    -------------------------------------------------------------------------
    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/

     

  • Raj14 Profile Picture
    9 on at

    Thanks @Agnius 

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 389

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard