I am trying to take just the HOUR out of a date time column in PowerBI.
, which is converted into
= Table.AddColumn(#"Reordered Columns", "Custom", each HOUR([LocalTime]))
but I get
Expression error: The name 'HOUR' wasn't recognized. Make sure it's spelled correctly.
I have scoured the internet, anyone have a place I can look for the answer?
Solved! Go to Solution.
=time.hour([DateTime]) is not working in my case. I don't know what's wrong.
I have this scenario:
Instead of each StartOfDay to be 12:00:00, the TradingDay begins at 5:00:00 AM of each day. So, my solution is to make a custom column that will determine the correct TradingDate for each transaction based on the given condition (i.e. 5:00:00 AM start of Trading Day). I got it to work in Excel thru HOUR() function but I can't get it to work in powerBI. My Excel formula is shown below.
can you help me with this please?
Thanks a lot.
@valQuentineCan you be more specific? What do you mean by "not working"? Is it giving you some sort of error message? Is it giving you an inaccurate result?
Thank you for a prompt reply @KHorseman.
I have tried this custom column in powerBI:
TradDate = IF(Time.Hour([DateTime])>4,[DateTime]+1,[DateTime])
And it returned an error "Failed to resolve name Time.Hour. It is not a valid table, variable, or function name."
What causes this error?
As I said earlier, Time.Hour() is a query formula, not a DAX formula. It's a different language, used only in the query editor. You appear to be trying to write a DAX formula in your table editor.
This is a must watch for a message from Power BI!
Click here to read more about the December 2020 Updates!
Click here to read the latest blog and learn more about contributing to the Power BI blog!
Mark your calendars and join us for our next Power BI Dev Camp!.