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 DURATION function?
The DURATION function is a date and time function in DAX that calculates the difference between two dates or times in a duration format. It is used to calculate the duration of an event, the time between two events, or the age of a person.
The syntax for the DURATION function is:
DURATION(❰time❱)
The time parameter can be a column or a scalar value that represents a time duration. The result of the DURATION function is always a duration value.
How does the DURATION function work?
The DURATION function works by subtracting the start time from the end time and returning the result in a duration format. The duration format is a decimal value that represents the number of days and fractions of a day between two times.
For example, if you want to calculate the duration between two dates, you can use the following formula:
DURATION([End Date] – [Start Date])
This will return the duration between the two dates in a decimal format.
How to use the DURATION function in Power BI
To use the DURATION function in Power BI, you need to follow these steps:
Step 1: Create a table with the start and end times
The first step is to create a table that contains the start and end times of the event you want to calculate the duration for. You can do this by importing a table from an external data source or creating a new table in Power BI.
Step 2: Create a new column with the DURATION function
Next, you need to create a new column in the table that uses the DURATION function to calculate the duration between the start and end times. You can do this by adding a new column to the table and using the following formula:
DURATION([End Time] – [Start Time])
Make sure to replace [End Time] and [Start Time] with the actual column names for the start and end times.
Step 3: Add the new column to your report
Once you have created the new column, you can add it to your Power BI report. You can do this by dragging and dropping the column onto the report canvas or adding it to a table or chart.
Step 4: Format the new column
Finally, you need to format the new column to display the duration in a readable format. You can do this by selecting the column in the Fields pane and selecting the duration format from the drop-down menu.
The DURATION function in DAX is a powerful tool that can help you calculate the duration between two dates or times in a decimal format. By following the steps outlined in this article, you can easily use the DURATION function in your Power BI reports to efficiently manage your data.