# QTD

The QTD function can be used to select data from a given measure, for the current quarter. If an offset parameter is provided, previous quarters will also be returned. It should be used in conjunction with an aggregate function like SUM or AVERAGE.&#x20;

## Syntax

```javascript
QTD(measure, offset)
```

## Arguments

measure – The measure for which data has to be fetched. Required.

offset -  Number of preceding quarters for which data has to be fetched. Optional.

## Return value

Range of data.

## Example

```javascript
QTD([Sales])
//Returns data from the Sales measure for the current quarter
QTD([Sales],5)
//Returns data for the past 5 quarters and the current quarter
```

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FTxSNGngU4GOZPgwRr6Fh%2Fimage.png?alt=media&#x26;token=56330e32-d005-4f41-a598-c10ca64f77ab" alt=""><figcaption><p>QTD without offset</p></figcaption></figure>

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FSROJt6yDwyQV8Lhdmh8c%2Fimage.png?alt=media&#x26;token=2a0f0ac8-e207-426a-9d83-0aace097bdf9" alt=""><figcaption><p>QTD with offset</p></figcaption></figure>
