How it works...

We start by creating the IsCurrentQuarter column. The IsCurrentQuarter column evaluates the current row's Value column, which contains dates. The IsCurrentQuarter column values are True if the date falls within the current quarter and False if the date does not fall within the current quarter. We do this by first getting the current date using the TODAY function and storing the value in the __Today variable. We then create the __CurrentYear and __CurrentQuarter variables, which store the YEAR and QUARTER for __Today. Next, we get the YEAR and QUARTER for the current row's Value column and store these in the __Year and __Quarter variables, respectively.  We now simply need to compare our __Year and __CurrentYear variables as well as our __Quarter and __CurrentQuarter variables. If __Year and __CurrentYear are equal to one another and __Quarter and __CurrentQuarter are equal to one another, then we return TRUE. Otherwise, if either __Year is not equal to __CurrentYear or __Quarter is not equal to __CurrentQuarter, then we return FALSE.

We can now use our IsCurrentQuarter column in the calculation of both of our DTS and DTS Sort By columns. The DTS column calculates a display value depending upon whether IsCurrentQuarter is True or False. If IsCurrentQuarter is True, DTS takes on the format W# - yyyy, where # is the week number of the year and yyyy is the four-digit year. If IsCurrentQuarter is False, DTS takes on the format Q# - yyyywhere # is the quarter number of the year and yyyy is the four-digit year.

Since we cannot be certain that our display value for our dynamic temporal scale, DTS, will sort correctly, we create DTS Sort By. The calculation for DTS Sort By is similar to DTS except that we return the concatenation of either YEAR, QUARTER, and WEEKNUM or YEAR and QUARTER