Referencing the Quarter Timeframe in table calcs

Knowledge Drop

Last tested: Jun 25, 2020
 

Say you're using a quarter timeframe that results in 2020-Q2, for example. If you were to create a table calculation referencing this, say

if(to_string(${quarter_field}) = "2020-Q2", ${arbitrary_field}, null)

You would never satisfy the Yes condition of the if() statement. This is due to the fact that quarter timeframes are being transformed via html from the format yyyy-mm to `yyyy-Qm`. We can confirm this is we open up the query in SQL Runner!

Solution

Since the quarter timeframes are actually appearing like "2020-01" for Q1, "2020-04" for Q2 and so on, you want to reference that date rather than the quarter format. Like so:

if(to_string(${quarter_field}) = "2020-04", ${arbitrary_field}, null)

Now you should see the Yes condition properly evaluated!

This content is subject to limited support.                

Version history
Last update:
‎07-07-2021 01:51 PM
Updated by: