Hello guys,
How can i change the '20170104' from column IDT_DTM_ID into 04-01-2017?
Kind regards,
Rega
Solved! Go to Solution.
No No,
u r trying to create in power Query window. so only it throws error.
i was gave u DAX Query.
U have to create new column in Development environment .
1. Create via Modelling Tab.
2. Right click on Table and choose new colum and apply the formula
Let me know if any help
assume: [date] is in the following format: yyyymmdd
create a new column named [dateFormatted] and apply the formula as follows:
select the new column and change its type to date as follows:
[dateFormatted] will now be of type date, formatted as: dd Mmm yyyy
New column with below formula worked for me
DateKey = FORMAT(Table1[DateColumn1].[Date],"YYYYMMDD")
I also found that this simple formula would convert your date from a YYYYMMDD string to a true date. Add as a new column:
DateFormatted = Date.From([IDT_DTM_ID])
If your date, is stored as an integer, (DateKey column), and not text, a slight tweak on @brentlightsey answer will do the trick:
Date.FromText( Number.ToText( [IDT_DTM_ID]))
You can then tweak the code in the advanced editor to add a data type conversion from text to a date value:
Original line:
#"Added Custom" = Table.AddColumn(MyDataSource, "DateFormatted", each Date.FromText( Number.ToText( [IDT_DTM_ID])))
Add type cast:
#"Added Custom" = Table.AddColumn(MyDataSource, "DateFormatted", each Date.FromText( Number.ToText( [IDT_DTM_ID])) type date)
You can do the type conversion in the Power Query Editor, but I like keeping the script as clean as possible and try to combine steps whenever possible.
assume: [date] is in the following format: yyyymmdd
create a new column named [dateFormatted] and apply the formula as follows:
select the new column and change its type to date as follows:
[dateFormatted] will now be of type date, formatted as: dd Mmm yyyy
Hi,
I'm little late but might help others...
The fastest and easiest solution is to use the the "Column from example" and your dates should be recognized after you type in a transformation of one of your date.
So the folowing formula will not be needed. In case you don't like code, it is the best way.
If you like to write your own code, there is a M function you can use in customn column:
Date.From(Text.From([#"DATE AUGMENT ATION"])) if you have a numeric column
or
Date.From([#"DATE AUGMENT ATION"])
(you also have the Date.fromText function, check out differences if needed)
Wishing you good transformation
I have a very simple way to do this in Power Query Editor (late, but might help others as @AilleryO also stated in his reply).
Three steps:
1. Change the date column type to Text
2. In case you have zero-values in your data (00000000), replace the 00000000 values with blank values, i.e. leave empty (this can be done in Transform tab --> Replace Values)
3. Change the date column type to Date
Note: If you don't need to do number 2., make a new step instead of replacing the previous one, otherwise it will skip the Text conversion and you'll end up of getting an error.
Create new column using DAX
Create new calculated Column
Hello,
Thank you for your message. i have cretated a new column and a new measure but i get the following error. there's something with the syntax for 4.
Create new column not measure.
OK, i created a custom column and these new column call DATUM.
Still i get a error of Expression.Error: The name 'DATUM' wasn't recognized...
what did i wrong?
No No,
u r trying to create in power Query window. so only it throws error.
i was gave u DAX Query.
U have to create new column in Development environment .
1. Create via Modelling Tab.
2. Right click on Table and choose new colum and apply the formula
Let me know if any help
for using data model, you need to use following expression when you add custom column
=Date.FromText( Text.Range([Input Date as Sting], 0,4) & "-" & Text.Range([Input Date as Sting], 4,2) & "-" & Text.Range([Input Date as Sting], 6,2) )
More information here:
https://msdn.microsoft.com/en-us/library/mt260703.aspx
Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Table5 is your table Name.
Column1 is your column name.
Do u want to change YYYYMMDD to date ? right.
my formula ii give u the date column as date, yyyy-mm-dd
Check out new user group experience and if you are a leader please create your group
100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.
User | Count |
---|---|
419 | |
189 | |
91 | |
84 | |
62 |
User | Count |
---|---|
471 | |
209 | |
138 | |
103 | |
87 |