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 / PowerApp update one, a...
Power Apps
Answered

PowerApp update one, and only one, value in a record

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

 

Hello,

 

I am having trouble trying to find and replace a value in a record. I have tried many combinations of Replace and Substitute, but to no avail. I can't seem to get it quite right.

 

The record is called myChosenLlist. myChosenList.items is a table nested within that record.

 

The myChosenList.items table looks like "Oregon, Washington, California, a". Note that the last value is just "a".

I want to change "a" to "Arizona", so the end result will be "Oregon, Washington, California, Arizona"

 

I want to set it to the renamedItemsList variable.

myChosenListItem is a variable with the value "Arizona" in this example.

 

The logic that I am using is:

 

 

Set(renamedItemsList,Substitute(Left(Concat(myChosenList.items,Value&", "),Len(Concat(myChosenList.items,Value&", "))-2),myChosenListItem,Trim(NewNameTextInput.Text)))

 

 

or, formatted

 

 

Set(
renamedItemsList,

Substitute(
Left(
Concat(
myChosenList.items,
Value & ", "
),
Len(
Concat(
myChosenList.items,
Value & ", "
)
) - 2
),
myChosenListItem,
Trim(NewNameTextInput.Text)
)
);

 


However, the result is now "Oregon, WArizonashington, CArizonaliforniArizona, Arizona". Note that the 1 a in "Washington" and the 2 a's in "California" are also substituted, which I do not want.

 

Am I approaching this incorrectly? Converting the table to string first, then substituting? Is there a cleaner way that works?

 

Thanks a lot in advance!

 

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous 

    You could try using Split to do what you need? Split returns a single column table with 'Result' as the column name.

     

    Here, I'm using Split on a string to create this table called colString:

    Set( vString, "Oregon, Washington, California, a");
    ClearCollect( colString, Split(vString,", "))

    If you then add a gallery (galString) and set it's Items property to colString, you can then use UpdateIf() to do what you need:

    ForAll(galString.AllItems, UpdateIf(colString ,Result="a", {Result: "Arizona"}))

     

    Granted, this isn't the exact code you need but I think it will give you all the pieces you need to do this?

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry for the long wait. 

    This is the code that I wrote.

     

     

    ForAll(
     myChosenList.items,
     UpdateIf(
     myChosenList.items,
    
     Value = myChosenPicklistItem,
     {Value: NewNameTextInput.Text}
     )
    );
    Set(
     renamedItemsList,
     Left(
     Concat(
     myChosenList.items,
     Value & ", "
     ),
     Len(
     Concat(
     myChosenList.items,
     Value & ", "
     )
     ) - 2
     )
    );

     

     It works fine!

     

    Thanks for the help!! 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 88

#2
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 45

Last 30 days Overall leaderboard