• 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

Text to Column of excel in power query|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Text to Column of excel 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 QueryText to Column of excel in power qu…
sp_PrintTopic sp_TopicIcon
Text to Column of excel in power query
Avatar
Eric Lei

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
April 20, 2020
sp_UserOfflineSmall Offline
1
April 20, 2020 - 5:44 pm
sp_Permalink sp_Print

Hi all,

 

This is related primarily to data type problem.

 

Let's say I have a column which contains both number and text, and in the excel interface when i do text to columns the numbers will be treated as numbers and text will stay as text.

 

When in power query I have changed the data type to any and when load onto excel the cells with numbers will need to perform a text to columns to be treated as numbers. So I want to know whether this can be done in power query so don't need to perform this extra step every time it refreshes.

 

The number is to perform vlookup in another excel table which I currently am still working on to do the calculations in power pivot, so in the mean time it needs to be load onto an excel sheet and perform vlookup there.

 

Because even if the numbers are the same but one in text and one in number the vlookup still returns #N/A so if forgetting to do text to columns there might be mistakes.

 

Thanks in advance for helping.

Avatar
Chris Yap
Member
Members
Level 0
Forum Posts: 162
Member Since:
August 21, 2019
sp_UserOfflineSmall Offline
2
April 20, 2020 - 7:03 pm
sp_Permalink sp_Print

Hi Eric,

So you had done split to column in Power Query,  you can change column in PQ to either Text or Number depending whether field require subsequent for computation

if you use Power Query then all use PQ and not vlookup ( in fact I would recommend Index & match instead),  for equivalent of vlookup in PQ will be Merge and it is quite easy and build only one time,   the primary key of both table need to be same data type (Text > Text,  or Number > Number

You can upload a sample worksheet and state what you want to achieve so we can help

Avatar
Eric Lei

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
April 20, 2020
sp_UserOfflineSmall Offline
3
April 20, 2020 - 8:03 pm
sp_Permalink sp_Print

Hi Chris,

 

Thank you for giving a quick reply.

 

Just to say that I currently have to have the result in an excel table to do further matching (vlookup or index match), so I cannot do merge queries.

 

You can see in the attached example what it currently shows when loaded compared to what I want (which is just one click of "text to columns" away)

 

And actually I now found out the problem is because my original data source is a csv file, and unlike normal excel files, in the query pane it will default to text data type (rather than "any" data type), and this causes my numbers data is considered text.

 

I have attached 2 identical files (1 in xlsx and 1 in csv). If you import both files in power query, you can see that csv file is defaulted to text data type, while xlsx is "any" data type; so when loaded onto excel sheet the xlsx file output have the numbers cells on the right (treated by excel as number), and the csv file output have the numbers cells on the left (treated by excel as text).

 

So actually my problem now is that if power query can treat csv file as "any" data type like xlsx file.

 

Thank you.

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4448
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
April 21, 2020 - 9:51 am
sp_Permalink sp_Print

Hi Eric,

Like Chris said, ideally you should be doing these VLOOKUPS/INDEX&MATCH lookups in Power Query, not in the worksheet. In Power Query a lookup is called a Merge. It does exactly the same thing as the VLOOKUP, so there really is no need to ever do a VLOOKUP or INDEX&MATCH in the worksheet again. If you use the Merge technique then you should format all of the lookup columns as 'text'.

That said, if you insist on using VLOOKUPS/INDEX&MATCH, you can manually change the data type in Power Query to 'any' by typing it in the formula bar of the Changed Type step. 

For example, when importing the CSV file the Changed Type step will look like this in the formula bar:

= Table.TransformColumnTypes(Source,{{"example", type text}})

Simply replace 'text' with 'any':

= Table.TransformColumnTypes(Source,{{"example", type any}})

I hope that helps.

Mynda

Avatar
Eric Lei

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
April 20, 2020
sp_UserOfflineSmall Offline
5
April 21, 2020 - 12:46 pm
sp_Permalink sp_Print

Hi Mynda,

 

Yes definitely ideally I would do this all within power query/ power pivot, but because now the calculation is done on an excel spreadsheet and I don't have time to implement it in power pivot just yet.

 

Actually after some googling I think it is because of the nature of CSV files that all data will be stored as text. So even like you suggested to do that change type to any, when loaded onto to excel sheet you still need a text to columns (or just double click the cell then enter) to make it interpreted as a number while if the source is in xlsx then it will be loaded as a number.

 

Anyway this is no big deal and I will just do text to columns in the mean time.

 

BTW, I have watched many of your videos and they have helped me on power query big time!

 

Thanks

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4448
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
6
April 21, 2020 - 4:32 pm
sp_Permalink sp_Print

No worries, Eric. One day when you get time you can overhaul the process to be more efficient and use Power Query. It's great to know you found my videos helpful 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 9
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:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6215
Posts: 27248

 

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