• 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

Transform Data using delimiters in Power Query |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Transform Data using delimiters in Power Query |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 QueryTransform Data using delimiters in …
sp_PrintTopic sp_TopicIcon
Transform Data using delimiters in Power Query
Avatar
Mike Bryan
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 28, 2020
sp_UserOfflineSmall Offline
1
February 12, 2023 - 5:49 am
sp_Permalink sp_Print

Hello All,

I am a novice power query user and am trying to automate a database of goalscorers for a football team by transferring one column with multiple names (each separated by a comma) into one column for each name (as per attachment #1). Now I can split column by each occurrence of the comma delimiter which gets me half way there (as per attachment #2).  The bit I'm struggling with is if a player has scored 2 or more goals then my source data includes the number of goals scored in brackets after the players name and in this case I then need to duplicate the players name on another column.

 

Any ideas on how I can get power query to identify if the player has a number in brackets after it and, if so, duplicate that players name again in as many new columns as the number in the brackets. I can then easily count the players name to find out the list of highest goalscorers. 

 

Any thoughts or assistance on this one would be hugely apprecited.

 

Thank youattachment-1.jpgImage Enlarger

attachment-2.jpgImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage attachment-1.jpg (16 KB)
  • sp_PlupImage attachment-2.jpg (38 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1511
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
February 13, 2023 - 12:05 pm
sp_Permalink sp_Print

Hi Mike,

Please see attached file for solution.  Looks like you are an Arsenal fan?  They're doing well this season, big game coming this week against City.

To get the result you wanted these are the steps I took (you can see the code in the query editor in PQ)

  1.  Split Scorer column by (delimiter) comma
  2.  Add an Index column which allows you to :
  3.  Unpivot the scorers columns into a single column
  4.  Filter out any rows containing penalties
  5.  Split the scorers column again by delimiter this time the delimiter is (
  6.  Remove any ) from the new column containing the number of goals scored
  7.  Replace og with null
  8.  Add a custom column that uses the List.Repeat function to create a list containing the name of any player who has scored more than 1 goal
  9.  Add a column that uses Text.Combine to create a comma delimited string from the lists created in Step 8
  10.  Remove all columns except the one that now contains the names of scorers
  11.  We now repeat Steps 1 to 3.  So split the column by delimiter (comma)
  12.  Add an Index column and ...
  13.  Unpivot the columns to leave you with a column containing the names of the scorers
  14.  Remove any unwanted columns
  15.  Trim the text in the scorers column to tidy it up.

You will of course need to apply this code to your own data as I had to create my own test data.  Please always supply an actual file if possible, rather than pictures.

Regards

Phil

scorersImage Enlarger

Avatar
Mike Bryan
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 28, 2020
sp_UserOfflineSmall Offline
3
February 14, 2023 - 7:17 am
sp_Permalink sp_Print

Hi Phil,

Thank you so much for looking at this. I would never have got there but the way you’ve set it out is super helpful and very logical. I really appreciate your time.

I see you’ve correctly identified the team. I’m actually practising my power bi skills by making a dashboard for my son who supports them. I’m a Plymouth Argyle fan who are ( for once!) doing quite well but much lower down the league pyramid!! 

All the best, and do please keep up the great work on your various video channels and website. You’re my ‘go to’ source for any excel related problems. Your knowledge and ability to communicate in simple terms is just so helpful.

 

thanks again,

Mike

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1511
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
February 15, 2023 - 8:16 am
sp_Permalink sp_Print

No worries Mike.  Thank you for your kind words, glad to know we are able to help.

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Ivica Cvetkovski
Blaine Cox
Shankar Srinivasan
riyepa fdgf
Hannah Cave
Len Matthews
Kristine Arthy
Michelle Neven
Andrew Kuhn
Angela Paul
Forum Stats:
Groups: 3
Forums: 24
Topics: 6206
Posts: 27202

 

Member Stats:
Guest Posters: 49
Members: 31875
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.