Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I was playing around with the DAX function CONVERT and was specifically trying to change an integer value to a datetime value.
So for example I have an integer column with the value of 20200527
I thought this would be easy to just simply write CONVERT(20200527, DATETIME) and I should get my date.
But apparently this gave an error?
I tried to search around and found someone had suggested the following formula
New Column = CONVERT(COMBINEVALUES("/",LEFT([DATE KEY],4),MID([DATE KEY],5,2),RIGHT([DATE KEY],2)),DATETIME)
Which works, but its just tedious to have to write out all the extra LEFT, MID, RIGHT etc.
Looking at this link: https://dax.guide/convert/
I see the following works just fine
Solved! Go to Solution.
If you directly enter a numeric value in the position of the expression, then the returned result is based on 1899/12/30 0:00:00 plus the numeric value .
For example :
Because Power BI doesn't know how to divide the numeric value into year, month, day, hour, minute and second .So the way you said to plug a straight integer field in without having to parse it is not feasible .
If you want to convert integer to date/time format , through Power Query or other dax .
Best Regards
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you directly enter a numeric value in the position of the expression, then the returned result is based on 1899/12/30 0:00:00 plus the numeric value .
For example :
Because Power BI doesn't know how to divide the numeric value into year, month, day, hour, minute and second .So the way you said to plug a straight integer field in without having to parse it is not feasible .
If you want to convert integer to date/time format , through Power Query or other dax .
Best Regards
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the detailed explanation @Anonymous !!
@rodneyc8063_1 , Try like
a new column =date(Quotient([Number], 10000) , Quotient(mod([Number], 10000),100), mod(mod([Number], 10000),100))
Thanks @amitchandak for the suggestion
I believe this should work as well, I just wish with the CONVERT function, we can just plug a straight integer field in without having to parse it, or put in sub functions. Was just curious if there was another (even lazier) way to convert 😛
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
216 | |
89 | |
82 | |
66 | |
57 |