• 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

How to just get the Month and Date from PowerQuery|Power Query|Excel Forum|My Online Training Hub

You are here: Home / How to just get the Month and Date from PowerQuery|Power Query|Excel Forum|My Online Training Hub

vba course banner

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 QueryHow to just get the Month and Date …
sp_PrintTopic sp_TopicIcon
How to just get the Month and Date from PowerQuery
Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
1
December 8, 2022 - 7:29 am
sp_Permalink sp_Print

How do I extract Month and Year from a date.  I have attached a screenshot.

I can extract the month and year and put it in a separate column but not together.  When I try to combine them it says it cannot combine string and numeric data together.  I know this is very simple for you guys but can you kindly guide me?

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
December 8, 2022 - 9:42 am
sp_Permalink sp_Print

Hi Steven,

There's no screenshot attached, you need to click on Start Upload after selecting the image.

But guessing at your data, if you are extracting the month and year using Date.Month and Date.Year then the result of both functions is a number.  You can't join numbers together like text strings, so you have to convert the numeric values to text first using Text.From

Text.From([Month]) & " " & Text.From([Year])

See attached file for an example.

regards

Phil

Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
3
December 8, 2022 - 10:39 am
sp_Permalink sp_Print

Sorry Phil for missing that step.  Here is that screensoht.  I am not sure if its helpful or I have given you enough information but if you have time please look at the attached screenshot.  Best Regards.

 

pqdattextract.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage pqdattextract.png (175 KB)
Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
4
December 8, 2022 - 10:47 am
sp_Permalink sp_Print sp_EditHistory

Phil, that worked perfectly.  Thank you for helping. I do have anothe question. I dont know if its appropriate to continue with anothe question in the same post.  If not please let me know. After completing with your solution I loaded the data into a pivot table.  I am trying to replicate a process which was manual into this PowerQuery solution.  What the original report had was subract the most current moth from the month before.   So in this case it would be December 2022 - November 2022 to get the variance.  The trick is as more data comes in how do I do this dynamically.  As each month comes in, so next month it would be January 2023 minus December 2022.  Is it possible to have powerquery to perform this.  I am uncertain as the Month and year cobination is a string so not sure if PowerQuery recognizes which one is the most current month and which one is one month less from the current.  

 

Thank you kindly.

 

Cpq3..JPGImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Cpq3..JPG (48 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
5
December 8, 2022 - 1:20 pm
sp_Permalink sp_Print

Hi Steven,

Can you please upload your file so I can work on that rather than recreate everything.

Regards

Phil

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
December 8, 2022 - 7:13 pm
sp_Permalink sp_Print

IMO you would be better off converting the dates to the 1st of the month so that you can use them as dates in calculations. You can always format the output to just show month name and year.

The following users say thank you to Velouria for this useful post:

Philip Treacy
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: ash seth, Scott Miller, Franziska Reinbold
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: 217
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
David du Toit
leandro barbarini
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27795

 

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