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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SaulM
Frequent Visitor

Power Query importing excel date field mmm-yy(Dec-21) automatically to 12/21/2022

Hello everyone, 

 

I am banging my head trying to fix something what seems simple. I have some excel files with a column "Date" formated as "DEC-21"(text) and Power Query brings it in automatically as 12/21/2022, making the year "21" to a date and adding the year of 2022 (guessing the year it's imported). How can I fix this? I can't split by delimiter and then merg as it's automatically changing it to 12/21/2022.

 

Excel: DEC-21          Power Query: 12/21/2022

 

 

I appreciate any help.

 

Thanks,

Saul

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

If by "fix this" you mean you want to display it the same as in your original Excel sheet, then:

 

Your data in Excel is a Text string but Power Query is changing it to a Date.  All you need to do is ensure PQ treats it as text.

 

If you examine the Applied Steps window, you will see that (probably) the second step is something like "Changed Type".  If you select that step, you will see in the formula bar something like: 

 

=Table.TransformColumnTypes(Source,{{"Date", type date}})

 

There may be other column names and types also in that line.

ronrsnfld_0-1667091367693.png

 

All you need to do is edit that line to change type date to type text

ronrsnfld_1-1667091417272.png

 

If you mean something else by "fix this" then please explain precisely what you want.

 

View solution in original post

7 REPLIES 7
ronrsnfld
Super User
Super User

If by "fix this" you mean you want to display it the same as in your original Excel sheet, then:

 

Your data in Excel is a Text string but Power Query is changing it to a Date.  All you need to do is ensure PQ treats it as text.

 

If you examine the Applied Steps window, you will see that (probably) the second step is something like "Changed Type".  If you select that step, you will see in the formula bar something like: 

 

=Table.TransformColumnTypes(Source,{{"Date", type date}})

 

There may be other column names and types also in that line.

ronrsnfld_0-1667091367693.png

 

All you need to do is edit that line to change type date to type text

ronrsnfld_1-1667091417272.png

 

If you mean something else by "fix this" then please explain precisely what you want.

 

That's it, ronrsnfld!

I made that change in the import table, but I did not see it in the function. I found it in the function and made that change.

SaulM_0-1667227978652.png

Now, that it's in text and Mmm-yy format, I was able to split and merge again to make it Mmm-yy and Date format.

SaulM_1-1667228004704.png 

SaulM_2-1667228335990.png

 

 

Thanks for your help! Simple, but it got me.

Saul

v-yalanwu-msft
Community Support
Community Support

Hi, @SaulM ;

It is very strange that you can share your excel file to remove sensitive information? So that I can test it

How to upload PBI in Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Looks like my work network prevents me to share or connect to any fileshare sites, Yalan. I was able to recreate the sheet from scratch and it did the same thing within Power Query. Below are random number. If you type DEC-21 (no spaces) it will recreate the issue.

 

SaulM_0-1666993256607.png

 

 

Thanks!

Saul

v-yalanwu-msft
Community Support
Community Support

Hi, @SaulM ;

You could delete last step in power query.

vyalanwumsft_0-1666856831008.png

Then add custom column.

=Date.FromText(
    "20"& Text.AfterDelimiter([Date], "-")&"-"&
     Text.BeforeDelimiter([Date], "-")
     &"-1")

The final show:

vyalanwumsft_1-1666857066660.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcklN1jUyVIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Date.FromText(
    "20"& Text.AfterDelimiter([Date], "-")&"-"&
     Text.BeforeDelimiter([Date], "-")
     &"-1"))
in
    #"Added Custom"


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for help Yalan. That solution is does not work in this scenario. 

As soon as it's imported in, it Power Query automatically set's it to mm/dd/yyyy format in the 1st step.

 

SaulM_0-1666882771449.png

I am bringin it in from a function to combine all files to one table.

SaulM_1-1666882815251.png

SaulM_2-1666882850880.png

That's my problem. So I can't referance the date in Mmm-yy format in power query as it automatically thinks it's in mm/dd/yyyy format and giving the year the import year.

 

Thanks,

Saul

 

 

Ehren
Employee
Employee

Some questions:

  • How are these date values stored in Excel? Are they text or actual dates?
  • How are you importing them? Is the data in the current workbook, or an external workbook?
  • If the data is coming from an external workbook, what format is the workbook saved in (e.g. .xlsx or .xls)?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors