DATESQTD DAX Function (Time Intelligence)  Context Transition

Returns a set of dates in the quarter up to the last date visible in the filter context.

Syntax

DATESQTD ( <Dates> )
Parameter Attributes Description
Dates

The name of a column containing dates, a single column table containing dates, or a calendar reference.

Return values

Table An entire table or a table with one or more columns.

For a date column, a table containing a single column of date values. For a calendar, a table containing the primary column of each calendar category and the time-related columns.

Notes

In order to use any time intelligence calculation, you need a well-formed date table. The Date table must satisfy the following requirements:

  • All dates need to be present for the years required. The Date table must always start on January 1 and end on December 31, including all the days in this range. If the report only references fiscal years, then the date table must include all the dates from the first to the last day of a fiscal year. For example, if the fiscal year 2008 starts on July 1, 2007, then the Date table must include all the days from July 1, 2007 to June 30, 2008.
  • There needs to be a column with a DateTime or Date data type containing unique values. This column is usually called Date. Even though the Date column is often used to define relationships with other tables, this is not required. Still, the Date column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.
  • The Date table must be marked as a date table in the model, in case the relationship between the Date table and any other table is not based on the Date.
The result of time intelligence functions has the same data lineage as the date column or table provided as an argument.

Remarks

The dates argument can be any of the following:

  • A reference to a date/time column. In this case, a context transition applies because the column reference is replaced by
  • 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.
  • A calendar reference. You define a calendar in the model for calendar-based time intelligence. With a calendar, the result has the primary column of each calendar category and the time-related columns of the calendar. Also in this case, a context transition applies.

The result table includes only dates that exist in the dates column.

With a date column, the syntax:

DATESQTD ( <Dates> ) 

corresponds to:

DATESBETWEEN ( 
    <Dates>, 
    STARTOFQUARTER ( LASTDATE ( <Dates> ) ),
    LASTDATE ( <Dates> ) 
)

With a calendar, the last date of the result depends on the columns that the filter context filters:

  • If the filter context filters the column tagged as Day, the result ends with the last visible day.
  • If the filter context filters a column of another category, for example a week or a month column, the result ends with the last day of the last visible period of that category. The result does not go past the end of the quarter.
  • If the filter context filters only columns that no calendar tags, for example the day of the week, the result has all the days of the quarter that includes the last visible date.

For example, with a filter on the DateKey column from August 1 to August 13, 2008, DATESQTD ( Gregorian ) returns July 1 to September 30, 2008, and DATESQTD ( ‘Date'[Date] ) returns July 1 to August 13, 2008. With a date column, the result always ends with the last visible date.

If the filter context filters a column that another calendar tags as Week, a calendar without the Week category returns an error.

With a calendar, CALCULATE removes only the filters on the columns of the calendar. The filters on the other columns of the date table stay, for example a filter on the day of the week. With the date column of a table marked as a date table, CALCULATE removes all the filters on the date table.

This function is not supported in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

» 1 related article
» 3 related functions

Examples

--  DATESQTD returns the dates from the first day of the currently selected
--  quarter to the last date visible in the filter context.
EVALUATE
CALCULATETABLE (
    DATESQTD ( 'Date'[Date] ),
    'Date'[Date] = DATE ( 2007, 5, 12 )
)
ORDER BY [Date] ASC
Date
2007-04-01
2007-04-02
…
2007-05-11
2007-05-12
--  If the selection contains larger periods, it returns the QTD using
--  the end of the entire period.
--  The result is always a single-column table.
EVALUATE
    CALCULATETABLE ( 
        DATESQTD ( 'Date'[Date] ),
        'Date'[Date] >= DATE ( 2007, 2, 5 ) 
            && 'Date'[Date] <= DATE ( 2007, 5, 12 ) 
    )
ORDER BY [Date] ASC
Date
2007-04-01
2007-04-02
…
2007-05-11
2007-05-12
--  All time intelligence functions are designed to return a table
--  to be easily used in CALCULATE as a filter.
EVALUATE
{
    CALCULATE (
        CALCULATE (
            [Sales Amount],
            DATESQTD ( 'Date'[Date] )       -- 2007-04-01 : 2007-05-12
        ),
        'Date'[Date] = DATE ( 2007, 5, 12 )
    )
}
Value
1,392,069.38
--  This example shows the sales of the current month, and both the
--  quarter-to-date and year-to-date sales.
DEFINE
    MEASURE Sales[Sales QTD] =
        CALCULATE (
            [Sales Amount],
            DATESQTD ( 'Date'[Date] )
        )
    MEASURE Sales[Sales YTD] =
        CALCULATE (
            [Sales Amount],
            DATESYTD ( 'Date'[Date] )
        )
EVALUATE
SUMMARIZECOLUMNS (
    'Date'[Calendar Year Month Number],
    'Date'[Calendar Year Month],
    "Sales Amount", [Sales Amount],
    "Sales QTD", [Sales QTD],
    "Sales YTD", [Sales YTD]
)
ORDER BY [Calendar Year Month Number]
Calendar Year Month Number Calendar Year Month Sales Amount Sales QTD Sales YTD
200701 2007-01-01 794,248.24 794,248.24 794,248.24
200702 2007-02-01 891,135.91 1,685,384.15 1,685,384.15
200703 2007-03-01 961,289.24 2,646,673.39 2,646,673.39
200704 2007-04-01 1,128,104.82 1,128,104.82 3,774,778.20
… … … … …
200909 2009-09-01 709,610.40 2,613,714.44 6,931,979.13
200910 2009-10-01 806,738.22 806,738.22 7,738,717.35
200911 2009-11-01 868,164.01 1,674,902.23 8,606,881.36
200912 2009-12-01 746,933.50 2,421,835.73 9,353,814.87
--  With a calendar, DATESQTD uses the quarters of that calendar.
--  Gregorian and Weekly 445 are calendars defined on the Date table.
--  In Weekly 445, a quarter has 13 weeks from Sunday to Saturday.
--  Q3-2008 starts on June 29, 2008, in Weekly 445 and on July 1 in Gregorian.
DEFINE
    MEASURE Sales[Sales QTD] =
        CALCULATE ( [Sales Amount], DATESQTD ( Gregorian ) )
    MEASURE Sales[Sales QTD 445] =
        CALCULATE ( [Sales Amount], DATESQTD ( 'Weekly 445' ) )
EVALUATE
SUMMARIZECOLUMNS (
    'Date'[Date],
    DATESBETWEEN ( 'Date'[Date], DATE ( 2008, 6, 27 ), DATE ( 2008, 7, 3 ) ),
    "Sales Amount", [Sales Amount],
    "Sales QTD", [Sales QTD],
    "Sales QTD 445", [Sales QTD 445]
)
ORDER BY 'Date'[Date]
Date Sales Amount Sales QTD Sales QTD 445
2008-06-27 1497.501 2653466.8713000007 2679226.2233
2008-06-28 15149.319999999989 2668616.1913000005 2694375.5433000005
2008-06-29 44447.668000000005 2713063.859300001 44447.668000000005
2008-06-30 24976.87199999999 2738040.7313000006 69424.54
2008-07-01 16379.352000000003 16379.352000000003 85803.89199999999
2008-07-02 41016.17 57395.522 126820.06199999999
2008-07-03 35478.42 92873.942 162298.48200000002

Related articles

Learn more about DATESQTD in the following articles:

  • Time Intelligence in Power BI Desktop

    In Power BI Desktop (as of February 2016) you have to use DAX to apply calculations over dates (such as year-to-date, year-over-year, and others), but you do not have the Mark as Date Table feature. This article describes which scenarios are impacted and the possible workarounds. » Read more

Related functions

Other related functions are:

Last update: Nov 10, 2026   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://learn.microsoft.com/en-us/dax/datesqtd-function-dax

2018-2026 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Passed by Expression

This parameter is passed by expression and can be evaluated multiple times in different evaluation contexts.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of DATESQTD? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.