DATESINPERIOD function



Description

Returns a table that contains a column of dates that begins with the start_date and continues for the specified number_of_intervals.

Syntax

DATESINPERIOD (<dates>, <start_date>, <number_of_intervals>, <interval>) 

Parameters

Sr.No. Parameter & Description
1

dates

A column that contains dates.

2

start_date

A date expression.

3

number_of_intervals

An integer that specifies the number of intervals to add to or subtract from the dates.

4

interval

The interval by which to shift the dates.

The value for interval can be one of the following −

  • year
  • quarter
  • month
  • day

Return Value

A table containing a single column of date values.

Remarks

The dates parameter can be any of the following −

  • A reference to a date/time column.

  • A table expression that returns a single column of date/time values.

  • A Boolean expression that defines a single-column table of date/time values.

Constraints on Boolean expressions −

  • The expression cannot reference a calculated field.

  • The expression cannot use CALCULATE function.

  • The expression cannot use any function that scans a table or returns a table, including aggregation functions.

However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.

If the number specified for number_of_intervals parameter is positive, the dates are moved forward in time. If the number is negative, the dates are shifted back in time.

The interval parameter is an enumeration, not a set of strings. Hence, the values for interval should not be enclosed in quotation marks. Also, the values: year, quarter, month, day should be spelled in full when using them.

The result table includes only dates that are specified in the dates parameter.

Example

= CALCULATE ( 
   SUM (Sales [Sales Amount]), 
   DATESINPERIOD (Sales[Date], DATE (2015,1,1),3, MONTH)
) 
dax_functions_time_intelligence.htm
Advertisements