Forum Discussion
DAX in power query
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
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
7 Replies
- carogomez
Helper I
Thank for your help. Now the formula is ok for power query but now their is an error in the columns:
- Fowmy
Super User
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 🙂
- carogomez
Helper I
"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.
- mahoneypat
Microsoft Employee
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