Reputation: 21
How to convert integer
(112 format) in to date
using DAX formula?
The date is in integer format 20170727
and I want to convert it to the following 27/07/2017
.
Upvotes: 2
Views: 15526
Reputation: 33
I created a new column and set its type to date. The DAX for the new column I used is a variation of alejandro zuleta answer.
DateType =
IF('DW FactMeasurement PAC Daily Report'[DateKey] <> 0,
(LEFT('DW FactMeasurement PAC Daily Report'[DateKey],4)) & "-"
&(MID('DW FactMeasurement PAC Daily Report'[DateKey],5,2))& "-"
&(RIGHT('DW FactMeasurement PAC Daily Report'[DateKey],2))
)
Upvotes: 0
Reputation: 298
Both answers are correct, but I think just partially. The full method: The full porcess:
New column
YourColumnName=DATEVALUE('YourTable'[YourDateFieldINTEGER])
Modeling
you can change (and set as default) any date/time format.
I suggest you to use the same date/time format in all field it is more clear, and easier if you don't have to convert always your dates.
I hope it was useful.
Upvotes: 0
Reputation: 14108
One way to get this in pure DAX is:
=DATE(INT(LEFT([IntegerDate],4)),INT(MID([IntegerDate],5,2)),INT(RIGHT([IntegerDate],2)))
Replace IntegerDate
by the actual name of your integer date.
However it is better perform this transformations using PowerQuery
or a data integration tool of your preference.
Let me know if this helps.
Upvotes: 1