May 13, 2021
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?
VIP
Trusted Members
December 7, 2016
July 16, 2010
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
Answers Post
May 13, 2021
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"))
July 16, 2010
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
1 Guest(s)