TIME
A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
What is the TIME Function?
The TIME function is a DAX function that returns a time value based on the specified hour, minute, and second values. The syntax for the TIME function is as follows:
TIME(hour, minute, second)
Where:
- `hour`: The hour value (0-23).
- `minute`: The minute value (0-59).
- `second`: The second value (0-59).
The TIME function returns a time value in the format `hh:mm:ss`, where `hh` represents the hour, `mm` represents the minute, and `ss` represents the second.
Using the TIME Function in Power BI
To use the TIME function in Power BI, you can follow these steps:
1. Open a new or existing Power BI report.
2. Click on the "Modeling" tab in the ribbon.
3. Click on "New Column" in the "Calculations" group.
4. In the formula bar, enter the following formula:
Time = TIME(hour, minute, second)
5. Replace `hour`, `minute`, and `second` with the desired values.
6. Press Enter to create the new column.
The new column will be added to the data model and can be used in visualizations and calculations.
Examples of Using the TIME Function
Let's take a look at some examples of using the TIME function in Power BI.
Example 1: Creating a Time Table
One common use case for the TIME function is to create a time table that can be used for time-based calculations and visualizations. To create a time table, follow these steps:
1. Open a new or existing Power BI report.
2. Click on the "Modeling" tab in the ribbon.
3. Click on "New Table" in the "Calculations" group.
4. In the formula bar, enter the following formula:
TimeTable = ADDCOLUMNS(
CALENDAR(DATE(2021, 1, 1), DATE(2021, 12, 31)),
“Time”, TIME(HOUR([Date]), MINUTE([Date]), SECOND([Date]))
)
5. Press Enter to create the new table.
This formula creates a time table for the year 2021 with a granularity of one second. The time value is calculated based on the hour, minute, and second values extracted from the date column.
Example 2: Calculating Time Differences
Another use case for the TIME function is to calculate the difference between two time values. To calculate the time difference, follow these steps:
1. Open a new or existing Power BI report.
2. Click on the "Modeling" tab in the ribbon.
3. Click on "New Column" in the "Calculations" group.
4. In the formula bar, enter the following formula:
TimeDiff = [Time2] – [Time1]
5. Replace `Time1` and `Time2` with the names of the columns that contain the time values.
6. Press Enter to create the new column.
This formula calculates the time difference between two time values and returns the result in the format `hh:mm:ss`.
The TIME function is a powerful DAX function that can be used to create custom time-based calculations and visualizations in Power BI. By following the steps outlined in this article, you can start using the TIME function in your own Power BI reports and dashboards.