January 5, 2022
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?
October 5, 2010
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
January 5, 2022
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.
Trusted Members
Moderators
November 1, 2018
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 Treacy1 Guest(s)