Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sakamotothais
Helper III
Helper III

hour in power BI language M

Hi,

I need help, if anyone knows.

I have a datetime column in the table, I make the direct query connection. And I want to add a column by bringing only the time, hour.
However when I put language m formula like datetime.time or time.hour, the query is not supported.

 

Capture.PNG

 

Then I need to add -3 hours in the hour column that I'll add.

Can anyone guide me where I'm going wrong?

 

Code:

let
    Source = Sql.Database("10.0.6.70,1433", "DailyBookings34"),
    DMBookings_BookingByLeg = Source{[Schema="DMBookings",Item="BookingByLeg"]}[Data],
    #"Filtered Rows" = Table.SelectRows(DMBookings_BookingByLeg, each Date.From([BookingDate]) = Date.From (DateTime.LocalNow ()) or Date.From([BookingDate]) = Date.AddDays (Date.From (DateTime.LocalNow ()) , -1) or Date.From([BookingDate]) = Date.AddDays (Date.From (DateTime.LocalNow ()), -7)),
    #"Added Custom2" = Table.AddColumn(#"Added Conditional Column", "BKDate", each DateTime.From([BookingDate])),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom2",{{"BKDate", type datetimezone}}),
    #"Added Custom3" = Table.AddColumn(#"Changed Type", "Personalizado", each DateTime.Time([BKDate])),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom3",{{"Personalizado", type time}})
in
    #"Changed Type1"

thanks

1 ACCEPTED SOLUTION

Because you are using Direct Query mode, you have limited query capabilities; time intelligence functions are not supported.

 

See the article of September 25, 2017, Use DirectQuery in Power BI Desktop

Specializing in Power Query Formula Language (M)

View solution in original post

4 REPLIES 4
Interkoubess
Solution Sage
Solution Sage

Hi @sakamotothais,

 

Did you try Time.Hour([BKDate])?

 

Let us know.

 

Ninter.

 

Hi,

 

 I try but the query is not supported.

 

 Capture.PNG

 

Capture1.PNG

 

Note: My field is datetime when I make the formula it gets integer.

 

Thanks

Because you are using Direct Query mode, you have limited query capabilities; time intelligence functions are not supported.

 

See the article of September 25, 2017, Use DirectQuery in Power BI Desktop

Specializing in Power Query Formula Language (M)

Yeah, is true. 

I'll try to mount the dashboard with what's possible in the query editor M

 

Thanks

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.