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 / Using SUBSTITUTE with ...
Power Apps
Answered

Using SUBSTITUTE with old_text, new_text as values in a table/column

(0) ShareShare
ReportReport
Posted on by 27

I am trying to use SUBSTITUTE on a string that the user pastes into TextInput1.  The challenge is the "old text" parameter needs to check the below MAPPING_TABLE for any value in OLD_NAMES that matches any pattern in the pasted string and then returns the corresponding value in NEW_NAMES for the "new name" parameter.  Ultimately I am trying to automatically revise their pasted string with a new string with the substituted values from the table.  I am using Dataverse. 

 

I tried running this code as the Text property in Label1 but I am getting an error "Expected Text value".

ForAll(
    MAPPING_TABLE,
    Substitute(TextInput1.Text, ThisRecord.OLD_NAMES, ThisRecord.NEW_NAMES)
)

 

MAPPING_TABLE

OLD_NAMESNEW_NAMES
NantucketBoston
manwoman
fromwho lived in

 

Example:

user pastes in TextInput1: "There once was a man from Nantucket"

expected output in Label1: "There once was a woman who lived in Boston"

 

Case sensitivity shouldn't matter.

 

Your help is appreciated.  

Categories:
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @WoodworkingDad ,

     

    Please try this

    vxiaochenmsft_0-1717550271305.png

    vxiaochenmsft_1-1717550279862.png

    "There once was a man from "& Concat(Filter(ForAll(LIST63,If(OLD_NAMES in TextInput1.Text,NEW_NAMES,"")),!IsBlank( Value)),Value,"")

     

    Best Regards,

    Wearsky

  • WoodworkingDad Profile Picture
    27 on at

    thanks, i got this code to work but it only substitutes the first match. i need it to substitute everything that matches.  @WarrenBelz sorry to tag you but hoping you can take a look.  

     

    Substitute(
    Upper(TextInput1.Text),
    Upper(LookUp(collection, OLD_NAMES in TextInput1.Text, OLD_NAMES)),
    Upper(LookUp(collection, OLD_NAMES in TextInput1.Text, NEW_NAMES))
    )

     

  • Verified answer
    WoodworkingDad Profile Picture
    27 on at

    After 4 hours, I actually think i figured it out.  I used Upper(Last(FirstN(Filter(collection, OLD_NAMES in TextInput1.Text), 2)).OLD_NAMES) instead of LookUp and then nested the Substitute functions, incrementing N by 1 each time.  Works like a charm. 

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard