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 Apps / Text conversion using ...
Power Apps
Unanswered

Text conversion using Power App and a sharepoint list for the changes

(0) ShareShare
ReportReport
Posted on by 42

I have made an app with 2 pannels one on the left is a text input box and the one on the right is a text output.

what i would like to do is enter words on a sharepoint list under OLDTXT and NEWTXT and it replaces those words in the text and displays this on the right.

thought it would be a simple

Substitute(
 Script.Text,
 Words_1, OLDTXT ,
 Words_1, NEWTXT

 )

but alas power apps wont do it directly so i tried this

Refresh(Words_1);

ClearCollect(
 WordReplacements,
 Words_1
);

Refresh( Words_1) ;


ClearCollect(
 WordReplacements,
 Words_1
);

ClearCollect(
 ModifiedTextList,
 ForAll(
 WordReplacements,
 Substitute(Script.NEWTXT, OLDTXT)
 )
);

Set(
 ModifiedOutput,
 Concatenate(ModifiedTextList, " ")
)

but the modified text list doest work. and the modified output has 3 rows 1 with each change. I wanted it to just output 1 record with the 3 changes in it.

does anyone know how i can complete this I tried in excel too but failed (please be simple as I am a bit slow on Power Apps 😉

Categories:
  • gcmfaizan Profile Picture
    1,022 on at

    Hi @jacktherip ,

    It seems like you're trying to replace certain words in a text using values from a SharePoint list and display the modified text in an output panel. To replace words in the Script.NEWTXT with corresponding values from the SharePoint list (OLDTXT), you can use the Substitute function within a loop.

    To replace words in the Script.NEWTXT with corresponding values from the SharePoint list (OLDTXT), you can use the Substitute function within a loop.

     

     

    ClearCollect(
     WordReplacements,
     SharePointListName // Replace with the actual SharePoint list data source
    );
    
    ClearCollect(
     ModifiedTextList,
     ForAll(
     WordReplacements,
     Substitute(Script.NEWTXT, OLDTXT, NEWTXT)
     )
    );
    
    Set(
     ModifiedOutput,
     Concatenate(ModifiedTextList, " ")
    )

     

     

    Please accept it as solution if it helps you.

    Cheers,

     

  • jacktherip Profile Picture
    42 on at

    Thank you for the fast reply. 

     

    sorry I forgot to say that the converted text is in an input text box called script.

     

    I just realised it would be easier with a picture 🙂 Please see the photos below \/\/\/\/\/\/

     

    screen 1 is the test screen with input and output (you can see the 3 returns all with a change but not all as one)

     

    screen 2 is the data

     

    screen 3 is the collection

     

    the output I am looking to do is to get 

     

    CAR

    TRAIN

    AIRPLANE

     

    I changed the code to 

    (anonymize_1 is the connection name to the sharepoint list)
    
    
    
    Refresh(Anonymize_1);
    
    ClearCollect( WordReplacements, Anonymize_1); ClearCollect( ModifiedTextList, ForAll( WordReplacements, Substitute(Script.Text, OLDTXT, NEWTXT) ) ); Set( ModifiedOutput, Concatenate(ModifiedTextList, " ") )
    

     

     

    thank you for your help 

     

    screen3.JPG
    Screen2.JPG
    Screen1.JPG
  • gcmfaizan Profile Picture
    1,022 on at

    Hi @jacktherip ,

     

    Here's how you can achieve this:

    1. Collect Word Replacements: Collect the word replacements from the SharePoint list "WordReplacements" in the OnStart property of the app or whenever needed.

     

     

    ClearCollect(
     WordReplacements,
     SharePointListName
    );
    Process Input and Display Output: In the OnSelect property of a button (or any other trigger), process the input text, apply word replacements, and display the modified text in the "ModifiedOutput" text box.
    
    <li/code>ClearCollect(
     ModifiedTextList,
     Substitute(Script.Text, WordReplacements.OLDTXT, WordReplacements.NEWTXT)
    );
    
    Set(
     ModifiedOutput,
     Concatenate(ModifiedTextList, " ")
    );

    Display Modified Output: Set the Text property of the "ModifiedOutput" text box to the "ModifiedOutput" variable.

    I hope now it helps you.

     

     

  • jacktherip Profile Picture
    42 on at

    Hi, back again sorry.

     

    The word replacements works and give me a little list like screenshot1 and then I am guessing that modified text (screenshot2) list should put them all into a table then they get converted to one record in modifiedoutput. But this is where I think things dont go as expected as it goes into modifiedoutput (screenshot3) but they are still in 3 records. so I cant put them in the textbox as they arnt 1 item of Text but I can show them in gallery view but they come up as 3 seperate. (screenshot 4)

     

    soo close 🙂

     

    again thank you for your time and help.

     

     

    Screenshot3.JPG
    Screenshot1.JPG
    Screenshot2.JPG
  • jacktherip Profile Picture
    42 on at

    I couldnt add 4 screenshots. so here is number 4 🙂

    Screenshot4.JPG
  • gcmfaizan Profile Picture
    1,022 on at

    Hi @jacktherip ,

     

    It seems like you want to merge the individual lines from the ModifiedTextList collection into a single block of text, and you're encountering issues with the formatting.

    Let's address this issue and help you achieve the desired output:

    1. OnSelect Property of a Button: Here's an updated version of the code for the button's OnSelect property:

     

     

     

     

    ClearCollect(
     WordReplacements,
     Filter(Words_1, Script.Text in OLDTEXT)
    );
    
    ClearCollect(
     ModifiedTextList,
     ForAll(
     WordReplacements,
     Substitute(Script.Text, OLDTEXT, NEWTEXT)
     )
    );
    
    Set(
     ModifiedOutput,
     Concatenate(ModifiedTextList, Char(10) & Char(10))
    )

     

     

    In this code, I've modified the Concatenate function to include two Char(10) characters between each replacement. This will add an extra line break to separate each modified text, making them distinct paragraphs.

    With this code, when you click the "Convert" button, the modified text lines will be separated by two line breaks (Char(10)), creating paragraphs.

     

     

    Please mark my posts as solution, to help others. 

    Cheers!

  • jacktherip Profile Picture
    42 on at

    Super I get what we are trying to do but it doesnt

    fix the 3 records it carrys on as normal doing its 3 records.

     

    this is a frustrating but interesting puzzle..... sorry to drag you into something that has been driving me mad. 

     

    (the last version)

     

     

    ClearCollect(
     ModifiedTextList,
     ForAll(
     Anonymize_1,
     Substitute(Script.Text, OLDTXT, NEWTXT)
     )
    );
    
    
    
    ClearCollect( ModifiedTextList, ForAll( WordReplacements, Substitute(Script.Text, OLDTXT, NEWTXT) ) );
     Set( ModifiedOutput, Concatenate(ModifiedTextList, Char(10) & Char(10)) )

     

     

  • jacktherip Profile Picture
    42 on at

     I have had another bash at this today and I dont think it can be done. I have gone a bit "code blind" now. 

    if it helps anyone else I have sort of a work around in Excel =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2, $D$2, $E$2), $D$3, $E$3), $D$4, $E$4)

     

     

    from this guide here Excel: find and replace multiple values at once (ablebits.com)

     

    I will see how far i can push this one 😉

     

    thanks for trying.

     

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 Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard