Title: Get derived date dimension year or month
Tags: einstein-analytics;saql
Question: 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 &quot;_year&quot; 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?



Here is another answer: 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;



{'source': 'StackExchangeDataset', 'subset': 'salesforce.stackexchange.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:08/28/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<einstein-analytics><saql>', 'Title': 'Get derived date dimension year or month', 'ViewCount': 483, 'id': 318098, 'user_AboutMe': '<p>Salesforce enthusiast</p>\n', 'user_AccountId': 10157875.0, 'user_DisplayName': 'Instread', 'user_Reputation': 633.0, 'user_Views': 52.0, 'user_id': 41423.0}}