Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
veronica_zappp
Frequent Visitor

Year imported as Text but Date change is also incorrect

I have a perplexing issue.

My data is being imported from an Excel sheet. Power Query automatically changes this to text or a whole number (picture below is of text)

veronica_zappp_0-1668806392948.png

 

However, if I manually change the data type to Date, it is also incorrect:

veronica_zappp_1-1668806441824.png

I would really just like this to be a Year, formatted as a date. I could even handle 2005-06-15 (middle of the year). I should add that I cannot replace all the years as they are many... so would prefer not to. But right now this is not working for some of the visualizations I'm working with.

 

Any advice?

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @veronica_zappp 

 

You can open Power Query Editor and add a custom column with below code to get a date column with [Year]. This uses Power Query M function #date. You can change the month and day numbers per your need.

#date(Number.From([Year]), 6, 15)

vjingzhang_0-1669022422063.png

 

Then change this new column to Date type. 

vjingzhang_1-1669022715705.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

View solution in original post

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @veronica_zappp 

 

You can open Power Query Editor and add a custom column with below code to get a date column with [Year]. This uses Power Query M function #date. You can change the month and day numbers per your need.

#date(Number.From([Year]), 6, 15)

vjingzhang_0-1669022422063.png

 

Then change this new column to Date type. 

vjingzhang_1-1669022715705.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

Thank you!!! This worked for me 🙂 . I've been learning DAX but haven't crossed into the M frontier yet... many thanks again.

ChrisMendoza
Resident Rockstar
Resident Rockstar

@veronica_zappp - 'Year' by itself is not a date though. It is a whole number. Possibly you need to remove summarization 'sum' from the column in 'Column Tools > Properties' ribbon when you have the field selected?






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thanks, Chris. I had tried this earlier (I should have written that in my initial post) but it did not resolve the issue for me.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.