How can I extract the hour from a datetime in Power BI?

In Power BI, the hour can be extracted from a datetime value by using the HOUR function. This function takes a datetime value as input and returns the hour component of that value. It is useful for dividing datetime data into specific time intervals or for creating visualizations that require hour-based grouping. To use this function, simply select the datetime column in your dataset and apply the HOUR function to it. This will extract the hour portion of the datetime and create a new column with the hour values. This feature is particularly useful for data analysis and reporting tasks in Power BI.

Power BI: Extract Hour from Datetime


You can use the following syntax in DAX to extract the hour from a datetime in Power BI:

hour = HOUR('my_data'[Datetime])

This particular example creates a new column named hour that extracts only the hour from the column named Datetime in the table named my_data.

The following example shows how to use this syntax in practice.

Example: How to Extract Hour from Datetime in Power BI

Suppose we have the following table named my_data in Power BI that contains information about total sales made by some company at specific datetimes:

Suppose that we would like to extract the hour from each datetime in the Datetime column.

To do so, click the Table tools tab, then click the icon called New column:

Then type the following formula into the formula bar:

hour = HOUR('my_data'[Datetime])

This will create a new column named hour that contains only the hour from the the corresponding datetime in the Datetime column:

Power BI extract hour from datetime

For example:

  • The formula extracts 10 from 1/1/2024 10:15:00 AM.
  • The formula extracts 19 from 1/5/2024 7:15:23 PM.
  • The formula extracts 1 from2/15/2024 1:15:09 AM.

And so on.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x