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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
545
Frequent Visitor

Reverse the words in english only (there are two languages in the column)

I'm trying to reverse the words in english because they came out reversed for example koobecaf should be facebook, here's the catch, there are words in a different language which came out fine so i dont want to reverse those.

 

My idea is to reverse the cells with english letters only while leaving the other language(a-z, A-Z).

 

note: the other language does not use latin letters so that should make things easier.

1 ACCEPTED SOLUTION

let
    Source = Sql.Database(ServerAddress, DbName),
    dbo_DVDR_LEADSOURCES = Source{[Schema="dbo",Item="LEADSOURCES"]}[Data],
    #"Filtered Rows" = Table.SelectRows(dbo_DVDR_LEADSOURCES, each ([LEADSOURCE] <> 0)),
    Ad_Corrected = Table.AddColumn(#"Filtered Rows", "Corrected", each
      if List.ContainsAll({"a".."z", "A".."Z"} & Text.ToList(" .,/*-+=-!~';\/|"), Text.ToList([LEADSOURCENAME]))
      then Text.Combine(List.Reverse(Text.ToList([LEADSOURCENAME])))
      else [LEADSOURCENAME],
  type text)
in
    Ad_Corrected

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

4 REPLIES 4
545
Frequent Visitor

Screenshot 2024-03-04 084106.png

let
    Source = Sql.Database(ServerAddress, DbName),
    dbo_DVDR_LEADSOURCES = Source{[Schema="dbo",Item="LEADSOURCES"]}[Data],
    #"Filtered Rows" = Table.SelectRows(dbo_DVDR_LEADSOURCES, each ([LEADSOURCE] <> 0))
in
    #"Filtered Rows"

this is the code i have, when i tried to add yours it showed an Eof error @dufoq3  @Vijay_A_Verma 

let
    Source = Sql.Database(ServerAddress, DbName),
    dbo_DVDR_LEADSOURCES = Source{[Schema="dbo",Item="LEADSOURCES"]}[Data],
    #"Filtered Rows" = Table.SelectRows(dbo_DVDR_LEADSOURCES, each ([LEADSOURCE] <> 0)),
    Ad_Corrected = Table.AddColumn(#"Filtered Rows", "Corrected", each
      if List.ContainsAll({"a".."z", "A".."Z"} & Text.ToList(" .,/*-+=-!~';\/|"), Text.ToList([LEADSOURCENAME]))
      then Text.Combine(List.Reverse(Text.ToList([LEADSOURCENAME])))
      else [LEADSOURCENAME],
  type text)
in
    Ad_Corrected

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

dufoq3
Super User
Super User

Hi @545, you can try something like this

 

If you want to ass more characters to include in correction, you can add them into pink box

 

dufoq3_0-1709491686275.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKqlILVHIKM7MSc9zVYrViVbKzs9PSk1OdANzchOL0hNLivM8wbz0tJTiI71HFx5dCiLBQkf2HV0IFAWiwwuPLjy8FohXKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    Ad_Corrected = Table.AddColumn(Source, "Corrected", each
      if List.ContainsAll({"a".."z", "A".."Z"} & Text.ToList(" .,/*-+=-!~';\/|"), Text.ToList([Column1]))
      then Text.Combine(List.Reverse(Text.ToList([Column1])))
      else [Column1],
  type text)
in
    Ad_Corrected

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Vijay_A_Verma
Super User
Super User

Need examples of some sample data. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors