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!!
I`m having problems formulating in power bi query:
I want to add a column with 1 and 0, where 1 indicates the date is before from today and 0 if it is greated than today.
But there is an error and I don't understand why:
Can you tell me what i'm doing wrong?
Thanks
Solved! Go to Solution.
@carogomez , Power Query is also extremely strick with data type in calculation, if the column [fech] is of type Date, the formula should be what I wrote above; if DateTime, the formula should be this accordingly,
if [fech]<=DateTime.LocalNow() then 1 else 0
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
FYI that you can click in the cell next to the word Error to see the error (not on the word). In this case, you are comparing DateTime with Date which gives error. You need to convert your column to Date first, or, if you need DateTime, you need to remove DateTime.Date from DateTime.LocalNow() or add DateTime.Date around your column.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@carogomez
Check the Data Type of the following column, it has to be Date/Time, if not right-click and change it to Date/Time before adding the new column, also check if any error exists.
[fechainicio]
________________________
If my answer was helpful, please click Accept it as the solution to help other members find it useful
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
"Fechainicio": I changed the column type to Date/time and the error persist.
What else is happenning, can`t understand.
Thank you very much for your fast reply.
@carogomez , Power Query is also extremely strick with data type in calculation, if the column [fech] is of type Date, the formula should be what I wrote above; if DateTime, the formula should be this accordingly,
if [fech]<=DateTime.LocalNow() then 1 else 0
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Perfect, I applied all you told me, but is still persisting the error:
I made click in the error and this was the message.
Hi, @carogomez , power query is case-sensitive and there's a specific way to obtain today's date. You might want to try this formula
if [fech]<=DateTime.Date(DateTime.LocalNow()) then 1 else 0
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thank for your help. Now the formula is ok for power query but now their is an error in the columns:
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 |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |