cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
nhol
Advocate II
Advocate II

year format

Hi,


I have an Excel file with year column as 2017, 2016, 2015 etc. In addition I have a month colmun. When I source this Excel sheet, the year as oppose to the month column is not recognized by PowerBI as a date but an integer which can be summarized (under modeling tab the “Data Type” for the year column appears as a “Whole Number”).

When I’m trying to re-format this column into a date format it throws an error stating “We can’t automatically convert the column to Date type”. So I went and add a new column sourcing my year column and tried to reformat the new one.

Apparently this worked to some extent as all years got converted to 1905.

How this can be resolved.

 

Thanks

NirH@BIteam

1 ACCEPTED SOLUTION
dramus
Continued Contributor
Continued Contributor

If you need to sort the data my the month and year, you can create a new calculated field. 

 

month-year = format([month],"00")&"-"&[Year]

View solution in original post

3 REPLIES 3
ganesh575
Frequent Visitor

Hi NirH,

 

In Power BI, it’s impossible to set a year column to 'Date' type in “yyyy” format. If you change a column with just years into date type format, it will format your data into a date.

 

Why does it do this? Well, it's probably because there is really no reason to convert years to a Date field anyway. It doesn't give you any extra functionality or anything. You can use the year field however you want (as a filter, in a visual, in a measure) WITHOUT it being in Date format!

 

My suggestion: leave the column in whole number / integer format.

 

Hope this helps.

 


Ganesh

There are a lot of good reasons to have "year" as a date field. I do it in R all the time. "Year" as an integer/whole number doesn't make any sense. 

dramus
Continued Contributor
Continued Contributor

If you need to sort the data my the month and year, you can create a new calculated field. 

 

month-year = format([month],"00")&"-"&[Year]

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors