Forum Discussion
Months are not reflected as dates
- 4 years ago
You could create a "Custom Column" using this code below:
Date.FromText(
Number.ToText(
if [Month] = "January" then 1
else if [Month] = "February" then 2
else if [Month] = "March" then 3
else if [Month] = "April" then 4
else if [Month] = "May" then 5
else if [Month] = "June" then 6
else if [Month] = "July" then 7
else if [Month] = "August" then 8
else if [Month] = "September" then 9
else if [Month] = "October" then 10
else if [Month] = "November" then 11
else if [Month] = "December" then 12
else null
)
& "/1/"
& Number.ToText(Date.Year([Year]))
)Then you should be able to change the data type of that new column to Date.
-Steve
Thanks! My problem is that I import another table with a date column (year and month) which is recognized as a date. This is the date column from my other table. Because this table recogizes the month as a date, I can not combine the data from the two tables in one visual. I hope my explanation makes sense... Any idea how to fix this?
You could create a "Custom Column" using this code below:
Date.FromText(
Number.ToText(
if [Month] = "January" then 1
else if [Month] = "February" then 2
else if [Month] = "March" then 3
else if [Month] = "April" then 4
else if [Month] = "May" then 5
else if [Month] = "June" then 6
else if [Month] = "July" then 7
else if [Month] = "August" then 8
else if [Month] = "September" then 9
else if [Month] = "October" then 10
else if [Month] = "November" then 11
else if [Month] = "December" then 12
else null
)
& "/1/"
& Number.ToText(Date.Year([Year]))
)
Then you should be able to change the data type of that new column to Date.
-Steve
- Anonymous4 years agoNot applicable
Hi Steve,
Thanks a lot! This solved my problem.