I'm creating a derived date dimension in SAQL and wanted to find out if there was any way to get the year or month (or day or quarter) parts from it? Normally, adding an "_year" to the end of a standard date dimension achieves this:

q = group q by Date_1_year as 'Date1Year', count(q) as 'Count';

But this doesn't seem to work the same way on derived measures (even though the full derived date measure works):

q = foreach q generate toDate(case when 'Date_1_sec_epoch' is not null then 'Date_1_sec_epoch' else 'Date_2_sec_epoch' end) as 'DateToUse';
-- This line doesn't work:
q = foreach q generate DateToUse_year as 'DateToUseYear', count(q) as 'Count';
-- This line works:
-- q = foreach q generate DateToUse as 'DateToUse', count(q) as 'Count';

Is augmenting the calculated date from a custom formula field in the underlying dataflow the only way to get this right?


EA only generates these values for Dates loaded into a dataset: Einstein Analytics Dates

To achieve someting similar, you can use the toString()-function:

q = foreach q generate toString(newDate, "yyyy") as newDate_Year;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.