Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
YasserKhalill
New Member

Reverse strings in extracted column

Hello everyone

I am totally new Power BI Desktop. I have connected PDF to extract table and everything is OK but one of the columns extracted is in Arabic letters and mixed numbers and the Arabic strings appeared reversed. So I am trying to reverse the strings (letters only not the numbers)

 

example: 

10 مسا

should be

اسم 10

so the text would be reversed not the number

 

Please guide me step by step as I am newbie (I want to apply the reverse to the whole column)

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @YasserKhalill ,

 

Follow steps below to achieve your requirement .

 

1.Split this column.

1.png

 

 

 

 

 

 

2.Add column to reverse the string .

2.png

 

 

 

3.Merge column to combine the number column and reversed string column.

3.png

 

 

4.Remove the extra column.

 

The M code works.

Let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQuNl6Y/ON5UqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Text.Reverse([Column1.2])),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom", {{"Column1.1", type text}}, "en-US"),{"Custom", "Column1.1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column1.2"})
in
    #"Removed Columns"

You can download my test pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EYQ6Zofxvn9KtidMbk... .

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @YasserKhalill ,

 

Follow steps below to achieve your requirement .

 

1.Split this column.

1.png

 

 

 

 

 

 

2.Add column to reverse the string .

2.png

 

 

 

3.Merge column to combine the number column and reversed string column.

3.png

 

 

4.Remove the extra column.

 

The M code works.

Let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQuNl6Y/ON5UqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", Int64.Type}, {"Column1.2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Text.Reverse([Column1.2])),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Added Custom", {{"Column1.1", type text}}, "en-US"),{"Custom", "Column1.1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column1.2"})
in
    #"Removed Columns"

You can download my test pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EYQ6Zofxvn9KtidMbk... .

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you very much Amy for great help.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.