Dax Function: TIME
Category: Date and Time Functions
The TIME function in Power BI constructs a time value based on three integer inputs: hours, minutes, and seconds.
Purpose
To create a valid time value from individual components (hour, minute, second).
Type of Calculations
This function performs time composition by combining numeric inputs into a single time value.
Practical Use Cases
- Creating time values from separate columns or inputs.
- Standardizing time-based data for analysis.
- Handling time-only data in calculations and visualizations.
TIME(<hour>, <minute>, <second>)</second></minute></hour>
| Parameter | Type | Description |
|---|---|---|
hour | Integer | Represents the hour (0–23). Values outside this range wrap around (e.g., 25 becomes 1). |
minute | Integer | Represents the minutes (0–59). Values outside this range adjust the hour accordingly. |
second | Integer | Represents the seconds (0–59). Values outside this range adjust the minutes accordingly. |
How Does TIME Dax Function Works
The TIME function combines the integer inputs for hours, minutes, and seconds into a single time value. If any input is outside its usual range, the function automatically adjusts the higher-order components (e.g., minutes and hours) to ensure the returned value is valid.
For example:
TIME(23, 90, 0)→ Returns00:30:00because 90 minutes is converted to 1 hour and 30 minutes.TIME(25, 0, 0)→ Returns01:00:00because 25 hours wraps around to 1 hour.
Internally, the function uses modular arithmetic to handle overflow and maintain consistency.
What Does It Return?
- Type: Datetime.
- Meaning: Returns a time value in the format
hh:mm:sswith fractional seconds if applicable.
When Should We Use It?
- Constructing time values from raw or separated data inputs.
- Standardizing time for calculations in models or dashboards.
- Generating time values dynamically in calculated columns or measures.
Examples
Basic Usage
Create a time value from individual components:
ConstructedTime = TIME(10, 30, 45)
Output: 10:30:45.
Column Usage:
Combine columns to create a unified time column:
CombinedTime = TIME(Table[Hour], Table[Minute], Table[Second])
Output: Returns a time value for each row in the table.
Advanced Usage
Use TIME to calculate the end time of an event:
EventEndTime = TIME(HOUR(Table[StartTime]) + 1, MINUTE(Table[StartTime]), SECOND(Table[StartTime]))
Output: Adds 1 hour to the StartTime column for each row.
Tips and Tricks
- Input Validation: Ensure inputs are integers to avoid unexpected results.
- Handling Overflow: Use overflow behavior to your advantage for dynamic time calculations.
- Combine with DATE: Use the DATE function to combine a time value with a date value for full datetime calculations.
- Formatting: Use Power BI formatting options to customize the display of the resulting time value.
Potential Pitfalls
- Non-Integer Inputs: Inputs must be integers; fractional values may cause errors.
- Invalid Wraparound Logic: Large numbers can create unintended results if not handled properly.
- Time Zone Handling: The function does not account for time zones; additional logic may be required.
Performance Impact of TIME DAX Function:
- Ensure input columns or measures are pre-processed or indexed for optimal performance.
- Avoid complex time calculations in calculated columns for large datasets; prefer measures where possible.
Related Functions You Might Need
- HOUR: Extracts the hour component from a datetime value.
- MINUTE: Extracts the minute component from a datetime value.
- SECOND: Extracts the second component from a datetime value.
- DATE: Constructs a date value from year, month, and day inputs.
- NOW: Returns the current datetime value.
Want to Learn More?
For more information, check out the official Microsoft documentation for TIME 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.
It constructs a time value using hour, minute, and second inputs.
Yes, the function adjusts overflow inputs (e.g., 65 minutes → 1 hour 5 minutes).
No, the function does not handle time zones; additional logic is required for such calculations.
Non-integer or invalid inputs will result in an error. Ensure inputs are properly validated.
Use the DATE function to create a datetime value:
DATETIME(DATE(2025, 2, 10), TIME(14, 30, 45))