cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How can I reverse a string ?

Hi,

 

I need to reverse a string in PowerApps as follows:

"HelloWorld"    -->   "dlroWolleH"

 

This string's length is variable and i tried to use Table function i.e. I separate my string in character, I enter these characters in a table. Then, I would like to add an "ID" column that automatically increments for each occurrence. Finally, I concatenate my table by sorting it in descending order

 

Do you how to add this type of column in this situation or may be do you have an other solution to reverse a string .

 

I thank you in advance for your help !

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: How can I reverse a string ?

One approach could be:

 

  • Create a button (action) which does the following:
ClearCollect(colReverse,Split( "HelloWorld", "" ));
Clear(colReverseOrder);
ForAll(colReverse,Collect(colReverseOrder,{Result:colReverse[@Result],Order:CountRows(colReverseOrder)+1}))

 

This creates one collection (colReverse) with all the letters in the word as a separate row. After that, it creates another collection (colReverseOrder) which adds a column "Order" to the previous collection with the (number of the) order of the specific letter.

 

  • Add a label to show the collection (colReverseOrder) in a reversed order and all rows concatenated:
Concat(SortByColumns(colReverseOrder,"Order",Descending),Result) 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Re: How can I reverse a string ?

One approach could be:

 

  • Create a button (action) which does the following:
ClearCollect(colReverse,Split( "HelloWorld", "" ));
Clear(colReverseOrder);
ForAll(colReverse,Collect(colReverseOrder,{Result:colReverse[@Result],Order:CountRows(colReverseOrder)+1}))

 

This creates one collection (colReverse) with all the letters in the word as a separate row. After that, it creates another collection (colReverseOrder) which adds a column "Order" to the previous collection with the (number of the) order of the specific letter.

 

  • Add a label to show the collection (colReverseOrder) in a reversed order and all rows concatenated:
Concat(SortByColumns(colReverseOrder,"Order",Descending),Result) 

 

View solution in original post

Anonymous
Not applicable

Re: How can I reverse a string ?

Thank you for your response @Anonymous !

 

Sorry but I don't understant what does [@Result] correspond to ?

Anonymous
Not applicable

Re: How can I reverse a string ?

Ok, nevermind @Anonymous , I figured it out. ^^'
It just refers to the Result column of colReverse (It seemed too simple x) )

Anonymous
Not applicable

Re: How can I reverse a string ?

In the first collection (colReverse), each individual character is stored automatically in a column called Result. This is a result Smiley Wink of using the Split-function.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,775)