Forum Discussion
Learning PowerBI: Why do functions return "function" in a table, instead of actual "value"?
Ok... so I'm trying to learn the basics of Power BI, and I have a few points that are just down right confusing...
This isn't specific to DateTime, but I'm using it as a sample function...
If I run this code:
#"Renamed Columns2" = Table.AddColumn(#"Renamed Columns1", "Executed", each DateTime.LocalNow()),
The system returns a "Function" hyperlink in the Executed column.
However, if I run this code:
#"Renamed Columns2" = Table.AddColumn(#"Renamed Columns1", "Executed", each DateTime.Date(DateTime.LocalNow())),
The system returns the current date.
Question: DateTime.LocalNow(), as I understand, returns the local date when executed as a date value. Why then do I have to use the additional DateTime.Date() to convert it from a "Function" hyperlink to the actual value.
Hi Anonymous ,
I tried both scenarios in Power BI at my end.
- Created a custome column "test" using DateTime.LocalNow(). This gave me the current value in date-time format.
- Created a custom column "test1" usingDateTime.Date(DateTime.LocalNow()). This gave me the current value indate format.
Just wanted to check if you can paste screenshot of the FUNCTION message which you are getting while using DateTime.LocalNow() as I don't get any such message at my end?
If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂
Thanks,
Pragati
7 Replies
- Pragati11Super User
Hi Anonymous ,
I tried both scenarios in Power BI at my end.
- Created a custome column "test" using DateTime.LocalNow(). This gave me the current value in date-time format.
- Created a custom column "test1" usingDateTime.Date(DateTime.LocalNow()). This gave me the current value indate format.
Just wanted to check if you can paste screenshot of the FUNCTION message which you are getting while using DateTime.LocalNow() as I don't get any such message at my end?
If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂
Thanks,
Pragati
- RaphaelMNew Member
You were probably missing the " ( ) " at the end of the function.
If you call DateTime.LocalNow , the output is going to be FunctionIf you call DateTime.LocalNow(), the output is going to be the real current date, for example, 2024-08-05.
- JRDFrequent Visitor
Thanks! That's what i was doing wrong
- parry2kSuper User
Anonymous I don't know why you are getting function, DateTime.LocalNow() should return date/time (date with timestamp)
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
- v-xicaiCommunity Support
Hi Anonymous ,
The DateTime.LocalNow() returns a datetime value set to the current date and time on the system.. See more:https://docs.microsoft.com/en-us/powerquery-m/datetime-localnow.
The DateTime.Date Convert DateTime format into Date format in Query Editor, see more: https://docs.microsoft.com/en-us/powerquery-m/datetime-date.
Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.