• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

New value based on what previous column value starts with...|Power Query|Excel Forum|My Online Training Hub

You are here: Home / New value based on what previous column value starts with...|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 QueryNew value based on what previous co…
sp_PrintTopic sp_TopicIcon
New value based on what previous column value starts with...
Avatar
Amar Sohal

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
1
June 11, 2020 - 5:44 am
sp_Permalink sp_Print sp_EditHistory

Hi all

I am very new to Power Query and am struggling with the M language it uses. I see the potential it has so have embarked on a project that will need me to utilise it if I am to succeed. 

Very long story short...I have a bunch of alphanumeric values in one column - some start with a letter, some a number. If the value starts with a number, then I need the new column to add a zero to the beginning of it (and copy across), otherwise just copy the existing value across as is.

I would really appreciate it if someone could point me in the right direction...example in Excel attached >>> 

PQ.PNGImage Enlarger

 

Regards

Amar

sp_PlupAttachments Attachments
  • sp_PlupImage PQ.PNG (11 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
June 11, 2020 - 10:10 am
sp_Permalink sp_Print

Hi Amar,

Yes Power Query is a fantastic tool but for this problem you don't need to use it.  You can achieve what you want with functions :

=IFERROR(IF(NUMBERVALUE(LEFT(B2,1)),"0"&B2,B2),B2)

Please see attached file.

regards

Phil

Avatar
Amar Sohal

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
3
June 12, 2020 - 1:41 am
sp_Permalink sp_Print

Hi Phil

Thank you for coming back to me so quickly, much appreciated.

The reason I need that task to be done in Power Query is so that it is automated. The raw dataset I am using is vast and in bad shape, so there are steps previous to that, that PQ is already preforming (perfectly) and there will be steps afterwards.

The first two digits of that field represent a Department and I have a mapping table that I will pull in afterwards on the basis of those two digits - along several other things before I can complete the model.

I am sure that formula will come in handy at some point though, thanks!

 

Regards

Amar

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4515
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
June 12, 2020 - 9:50 am
sp_Permalink sp_Print

Hi Amar,

This is why it's very important to give the whole picture of what you're trying to do and why.

You can use this Power Query formula in a 'Custom Column':

= if Value.Is(Number.FromText(Text.Start([Column1],1)), type number) then "0"&[Column1] else [Column1] otherwise [Column1])

 

Mynda

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Magnolia Stellata
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27793

 

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