Dax Function: HOUR

Category: Date and Time Functions

The HOUR function in Power BI is a DAX (Data Analysis Expressions) function used to extract the hour component from a datetime value.

Purpose

To retrieve the hour as an integer (0–23) from a given datetime or time value.

Type of Calculations

Time manipulation and analysis.

Practical Use Cases

  • Breaking down datetime data into hourly segments for analysis.
  • Identifying specific time periods (e.g., business hours vs. non-business hours).
  • Grouping data by hour for reporting or visualization.
				
					HOUR(<datetime>)
				
			
ParameterTypeDescription
datetimeDatetimeA valid datetime or time value from which the hour component will be extracted.

 

How Does HOUR Dax Function Works

  1. The function interprets the datetime input.
  2. It isolates the hour portion of the given time.
  3. The result is a number from 0 (midnight) to 23 (11:00 PM), based on a 24-hour clock format.

Example: For datetime = 2025-02-10 15:45:00, the result is 15.

What Does It Return?

  • Type: Integer.
  • Meaning: Returns the hour (0–23) of the given datetime value.

When Should We Use It?

  • Extracting time-based insights from datetime columns.
  • Identifying peak hours in sales or operations data.
  • Creating custom filters or conditions based on specific hours.

Examples

Basic Usage

Extract the hour from the current date and time:

				
					HOUR(NOW())
				
			

Output: If the current time is 2025-02-10 14:30:00, the result is 14.

Column Usage:

Add a calculated column to extract the hour from a datetime column:

				
					OrderHour = HOUR(Table[OrderDate])
				
			

For OrderDate = 2023-07-21 09:15:00, the result is 9.

Advanced Usage

Group sales data by hour and calculate total sales:

				
					TotalSalesByHour = SUMX(
    FILTER(Table, HOUR(Table[OrderDate]) = 14),
    Table[SalesAmount]
)
				
			

This calculates total sales for orders placed at 2:00 PM.

Tips and Tricks

  • Use HOUR alongside MINUTE and SECOND for more granular time-based analysis.
  • Pair with DATE or NOW to dynamically filter or segment data by hours.
  • Be cautious when working with time zones—ensure that datetime values are in the correct time zone for accurate analysis.

Potential Pitfalls

  • If the datetime parameter contains null or invalid values, the function will return an error. Use functions like ISBLANK or IFERROR to handle such cases.
  • The function does not support time formats outside standard datetime values. Ensure data is properly formatted.

Performance Impact of HOUR DAX Function:

  • Efficient for large datasets when used in calculated columns or measures.
  • Precompute hour values during data preparation in Power Query if performance becomes an issue.

Related Functions You Might Need

  • MINUTE: Extracts the minute component from a datetime value.
  • SECOND: Extracts the second component from a datetime value.
  • TIME: Combines hour, minute, and second values into a time.
  • NOW: Returns the current datetime.

Want to Learn More?
For more information, check out the official Microsoft documentation for HOUR. You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the HOUR function do in Power BI?

The HOUR function extracts the hour component (0–23) from a given datetime or time value.

2. Can HOUR work with time-only fields?

Yes, the function can handle time-only fields and will extract the hour portion.

3. What happens if the datetime input is null?

The function will return an error. Handle null values with IFERROR or ISBLANK.

4. How does HOUR handle 12-hour vs. 24-hour formats?

The function always returns the hour in a 24-hour clock format (e.g., 2:00 PM = 14).

5. Can I use HOUR to group data in a report?

Yes, you can extract the hour as a calculated column or measure and use it for grouping or segmentation.

Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.

 

Contact

WeWork Berger Delhi One, C-001/A2, Sector 16B, Noida, Uttar Pradesh 201301

0124-502-5592
info@lets-viz.com

We are Social

Trust Pilot Reviews