• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

List Function: Remove Specific Character From All Words|Power Query|Excel Forum|My Online Training Hub

You are here: Home / List Function: Remove Specific Character From All Words|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryList Function: Remove Specific Char…
sp_PrintTopic sp_TopicIcon
List Function: Remove Specific Character From All Words
Avatar
DigaloGuapo
Member
Members
Level 0
Forum Posts: 23
Member Since:
February 23, 2017
sp_UserOfflineSmall Offline
1
August 13, 2020 - 12:34 pm
sp_Permalink sp_Print

So the problem I have is in the way List.Contains works compared to Text.Contains.

I'm basically trying to transform plural words to singular words and List.Contains seems to require an exact match while Text.Contains is more approximate. However, in PowerBi it's much easier at times to pass in a list of values, especially if you're using conditional logic.

What I'm trying to do, if the final character in a list of words in a cell ends in "s" is to tell PowerBi/M Language to remove that "s" from ever word. This is why Text.Contains will not work, because it will only remove the "s" from the last word in the string.

Suppose I have a column called [Keyword] with the text "mens nikes shoes" in row 1, I'm tying to use a custom column to convert that to "men nike shoe"

So, I need a List function that will iterate over every word in a string and remove the "s" IF it is at the end of the text. I just needs some ideas of what might work. I think List.Transform might work but I don't know enough about how it to use it right now.

All ideas and suggestions will be greatly appreciated.

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
August 13, 2020 - 1:36 pm
sp_Permalink sp_Print sp_EditHistory

Before getting too far into this, are you sure that all words with an s at the end are plural?  What about tennis, as in 'womens tennis shoes'?

And that's ignoring that it should really be women's so removing the s from that leaves you with an apostrophe at the end of the word.

Phil

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
3
August 13, 2020 - 1:47 pm
sp_Permalink sp_Print sp_EditHistory

Please, always supply some dummy data so we don't have to create our own.

But, this will work

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","s "," ",Replacer.ReplaceText,{"Column1"}),
#"Inserted Trimmed Text" = Table.AddColumn(#"Replaced Value", "Trim", each Text.TrimEnd([Column1],"s"), type text),
#"Removed Columns" = Table.RemoveColumns(#"Inserted Trimmed Text",{"Column1"})
in
#"Removed Columns"

However it will remove the s from the end of every word so a word like tennis will be affected.

See attached.

Regards

Phil

sp_AnswersTopicAnswer
Answers Post
Avatar
DigaloGuapo
Member
Members
Level 0
Forum Posts: 23
Member Since:
February 23, 2017
sp_UserOfflineSmall Offline
4
August 14, 2020 - 12:45 am
sp_Permalink sp_Print

Thanks for time and help, Philip. Your points are well taken.

Looks like I'll have to go back to the drawing. The only solution is probably what I was looking to avoid --  a lot nested IF statements.

Thanks again!

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Catalin Bombea, Velouria
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 204
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Kathryn Patton
Maria Conatser
Jefferson Granemann
Glen Coulthard
Nikki Fox
Rachele Dickie
Forum Stats:
Groups: 3
Forums: 24
Topics: 6222
Posts: 27291

 

Member Stats:
Guest Posters: 49
Members: 31913
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.