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
Yannyqi
Frequent Visitor

Need help to remove few words within a column in Power BI

Hi everyone,

 

I am new to power bi and i would like to know if there is any way to remove some words within the whole column?

For eg. The variables within the property row are:

  1. Entire condo
  2. Private room in apartment
  3. Room in hotel
  4. Loft
  5. Room in apartment
  6. Shared room in condo
  7. Private room in hotel
  8. Tiny house
  9. Shared room
  10. Private room

I would like to remove the words "Entire",  "Private room in",  "Room in", "Shared room in"

 

Thank you very much in advance!

 

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Here is another one...

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs0rySxKVUjOz0vJV4rViVYKKMosSyxJVSjKz89VyMxTSCxILCrJTc0rAcsGQUUz8ktSc8AiPvlpqFKoGoIzEotSU+Cm4bYHYWJIZl4lkFtanIpuAoZGpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldText = _t]),
    Words = {"Entire", "Private room in", "Room in", "Shared room in"},
    FINAL = Table.AddColumn(Source, "NewText", each 
            Text.Trim (List.Accumulate( {0..List.Count(Words)-1}, [OldText], 
            (s,c) => Text.Replace( s, Words{c}, "" ))))
in
    FINAL

Jakinta_0-1623388269017.png

 

View solution in original post

4 REPLIES 4
Jakinta
Solution Sage
Solution Sage

Here is another one...

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs0rySxKVUjOz0vJV4rViVYKKMosSyxJVSjKz89VyMxTSCxILCrJTc0rAcsGQUUz8ktSc8AiPvlpqFKoGoIzEotSU+Cm4bYHYWJIZl4lkFtanIpuAoZGpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldText = _t]),
    Words = {"Entire", "Private room in", "Room in", "Shared room in"},
    FINAL = Table.AddColumn(Source, "NewText", each 
            Text.Trim (List.Accumulate( {0..List.Count(Words)-1}, [OldText], 
            (s,c) => Text.Replace( s, Words{c}, "" ))))
in
    FINAL

Jakinta_0-1623388269017.png

 

Hi @Jakinta ,

 

Thank you very much for the help.

 

CNENFRNL
Community Champion
Community Champion

let
    Kw = {"Entire",  "Private room in",  "Room in", "Shared room in"},
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs0rySxKVUjOz0vJV4rViVYKKMosSyxJVSjKz89VyMxTSCxILCrJTc0rAcsGQUUz8ktSc8AiPvlpqFKoGoIzEotSU+Cm4bYHYWJIZl4lkFtanIpuAoZGpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Type = _t]),
    #"Added Custom" = Table.AddColumn(Source, "New", each List.Accumulate(Kw, [Type], (s,c) => let pos=Text.PositionOf(s,c,1,Comparer.OrdinalIgnoreCase) in if pos<>-1 then Text.Trim(Text.RemoveRange(s,pos,Text.Length(c))) else s))
in
    #"Added Custom"

Screenshot 2021-06-10 211144.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi @CNENFRNL ,

 

Thank you very much for the help.

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