• 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
  • Login

recognize the month based on the name|Power Query|Excel Forum|My Online Training Hub

You are here: Home / recognize the month based on the name|Power Query|Excel Forum|My Online Training Hub

office scripts course

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 Queryrecognize the month based on the na…
sp_PrintTopic sp_TopicIcon
recognize the month based on the name
Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
1
May 28, 2021 - 2:18 am
sp_Permalink sp_Print

Hi-

my month column has the name of the month ie January/February listed. Is there a way for Query to recognize it as a Date/Month vs text?

sp_AnswersTopicSeeAnswer See Answer
Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 880
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
May 28, 2021 - 8:14 am
sp_Permalink sp_Print

Hello,

If you also have the year then yes. Check out the Date.FromText function.

Br,
Anders

Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
3
May 29, 2021 - 12:09 am
sp_Permalink sp_Print

Thank you- so if I don't have a year I'm stuck?

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4614
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
May 29, 2021 - 10:10 am
sp_Permalink sp_Print

Hi Moriel,

Welcome to our forum!

Like Anders suggested, you can use the Date.FromText function. If you don't have a year column in your data you can add it by entering it in the formula like so:

= Date.FromText("2021-"&[Month]&"-1")

 

Where [Month] is the name of the column containing your month names.

This will return a list of dates as at the first of each month name for 2021.

Mynda

sp_AnswersTopicAnswer
Answers Post
Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
5
June 2, 2021 - 12:44 am
sp_Permalink sp_Print

Firstly- Thank you very much for your help.

Second, I tried what you did- see below and I get the following error: Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

My Column's name is Month and the source data isn't consistent with the format so  first I made it all lower and then wanted to add the date. 

#"Lowercased Text" = Table.TransformColumns(#"Renamed Columns3",{{"Month", Text.Lower, type text}}),
#"Added Conditional Column" = Table.AddColumn("Lowercased Text", Date.FromText("2021-"&[Month]&"-1"))

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4614
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
6
June 2, 2021 - 9:12 am
sp_Permalink sp_Print

Hi Moriel,

Please share an extract of your Excel file that illustrates the error.

Mynda

Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
7
June 3, 2021 - 12:05 am
sp_Permalink sp_Print

Here is my file-

 

Thank you,

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4614
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
8
June 3, 2021 - 9:41 am
sp_Permalink sp_Print

Hi Moriel,

Your file didn't get uploaded. After selecting the file you need to click the 'start upload' button and wait for the green text notification that appears briefly below the attachment window to tell you the file has finished uploading.

Mynda

Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
9
June 4, 2021 - 12:19 am
sp_Permalink sp_Print

Mynda-

Thank you for your patience. Here it is.

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4614
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
10
June 4, 2021 - 5:27 pm
sp_Permalink sp_Print

Hi Moriel,

Thanks for sharing your file. Unfortunately, the source data is somewhere else, so when I open the query I get an error. However, I used the data on the sheet called 'table' and was able to add the calculated column. My step looks like this:

= Table.AddColumn(#"Lowercased Text", "Month Number", each Date.FromText("2021-"&[Month]&"-1"))

Whereas yours looks like this, with no reference to the previous step or maybe it's the column name missing, either way, there's an argument missing from the formula:

= Table.AddColumn("Lowercased Text", Date.FromText("2021-"&[Month]&"-1"))

Hope that helps.

Mynda

Avatar
moriel hamui
Member
Members
Level 0
Forum Posts: 24
Member Since:
May 13, 2021
sp_UserOfflineSmall Offline
11
June 4, 2021 - 11:52 pm
sp_Permalink sp_Print

Thank you very much- yes  I was missing the column name- thank you again for your help

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Susan VanRiper, QSolutions Group
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
jaryszek: 183
Newest Members:
Herbie Key
Trevor Pindling
Stevan Kanjo
Erin Sheldon
Nikita Bhatia
Sheilah Taylor
Clare Webber
David Jenssen
Dominic Brosnahan
Young You
Forum Stats:
Groups: 3
Forums: 24
Topics: 6526
Posts: 28575

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • 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

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

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

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.