THIS Macro

THIS macro references the current value for the specified attribute of the Date dimension.

In the following example, THIS macro inherits the day granularity from the Date attribute. Here THIS means this date, or “today”:

SELECT Payment WHERE Date = THIS

If the granularity of the date attribute changes, so does the meaning of THIS.

Using arithmetic with THIS

You can use addition and subtraction with THIS macro to reference future or previous time periods. For example, suppose the current date is November 3, 2014.

With the following MAQL expressions,

SELECT COUNT Event WHERE <date_attribute> = THIS + 2
SELECT COUNT Event WHERE <date_attribute> = THIS - 2

THIS macro returns date attribute values as shown in the following table:

Date attribute (partial list)

Current value

THIS + 2

THIS - 2

Date

11/3/2014

11/5/2014

11/1/2014

Day of Week

Monday

Wednesday

Saturday

Month

11 (November)

1 (January)

9 (September)

Quarter

Q4

Q2

Q2

Quarter/Year

Q4/2014

Q2/2015

Q2/2014

Notice that if the date attribute is periodic, such as quarter (Q1, Q2, Q3, Q4) or month (January, February, March, etc), using addition or subtraction with THIS macro can make the date attribute roll over or backward to the next or previous period.

THIS - 1 is identical to PREVIOUS. THIS + 1 is identical to NEXT. To reference the previous or next time period, use the PREVIOUS or NEXT macro. See PREVIOUS Macro or  NEXT Macro.