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.
Hi everyone
I try to use the formula year(ordPubAno); ordPub ano is formatted as whole number.
The result of conversion for example for 2004 is 1905 but it should be 2004.
I try to convert also a month(ordPubMês) odrPubMes is formatted as whole number and for example for 8 convert to 1 instead of 8.
Can you help?
Solved! Go to Solution.
The YEAR and MONTH functions expect a datetime object, not an integer. When you pass an integer, DAX assumes that is the number of days that have passed since Dec 31, 1899. So when you get the YEAR(2004), you're actually getting the year 2004 days after Dec 31, 1899. Same with MONTH(8), which returns 1 since 8 days after Dec 31, 1899 it is January.
My question is why you're trying to convert a value that is a year into a year? You're expecting a result of 2004 when you input 2004 into the function. You already have the value you're expecting to come out of the function, so just use that.
The YEAR and MONTH functions expect a datetime object, not an integer. When you pass an integer, DAX assumes that is the number of days that have passed since Dec 31, 1899. So when you get the YEAR(2004), you're actually getting the year 2004 days after Dec 31, 1899. Same with MONTH(8), which returns 1 since 8 days after Dec 31, 1899 it is January.
My question is why you're trying to convert a value that is a year into a year? You're expecting a result of 2004 when you input 2004 into the function. You already have the value you're expecting to come out of the function, so just use that.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |