Skip to main content

Hello, I need assistance with a SAQL query. I am trying to get a timeseries for a field I have on the case object. Before turning on the time zone, this is the working query I had.

 

I want to group the data by year and month and have the average time to first response. I then want to generate a timeseries to generate the prediction using the 95 interval.

q = load "CaseRecipeDataset";q = group q by ('CreatedDate_Year', 'CreatedDate_Month');q = foreach q generate 'CreatedDate_Year', 'CreatedDate_Month', avg('Time_To_First_Response__c') as 'avg_Time_To_First_Response__c';q = fill q by (dateCols=('CreatedDate_Year','CreatedDate_Month', "Y-M"));q = timeseries q generate 'avg_Time_To_First_Response__c' as 'Time_To_First_Response__c' with (length=12, predictionInterval=95, dateCols=('CreatedDate_Year', 'CreatedDate_Month', "Y-M"), seasonality=12);q = foreach q generate 'CreatedDate_Year' + "~~~" + 'CreatedDate_Month' as 'CreatedDate_Year~~~CreatedDate_Month', coalesce('avg_Time_To_First_Response__c', 'Time_To_First_Response__c') as 'Time_To_First_Response__c', 'Time_To_First_Response__c_low_95', 'Time_To_First_Response__c_high_95';q = order q by 'CreatedDate_Year~~~CreatedDate_Month' desc;q = limit q 30;

However after turning on timezone this no longer works with the timeline chart (even though I see data in the table view). I have tried to convert to use timezone syntax below but it keeps telling me CreatedDate is an undefined identifier. 

 

q = load "CaseRecipeDataset";q = group q by (year('CreatedDate'), month('CreatedDate'));q = foreach q generate year('CreatedDate') as 'CreatedDate_Year', month('CreatedDate') as 'CreatedDate_Month', avg('Time_To_First_Response__c') as 'avg_Time_To_First_Response__c';q = fill q by (dateCols=('CreatedDate_Year','CreatedDate_Month', "Y-M"));q = timeseries q generate 'avg_Time_To_First_Response__c' as 'Time_To_First_Response__c' with (length=12, predictionInterval=95, dateCols=('CreatedDate_Year', 'CreatedDate_Month', "Y-M"), seasonality=12);q = foreach q generate year('CreatedDate') + "-" + month('CreatedDate') as 'Year-Month', coalesce('avg_Time_To_First_Response__c', 'Time_To_First_Response__c') as 'Time_To_First_Response__c', 'Time_To_First_Response__c_low_95', 'Time_To_First_Response__c_high_95';q = order q by 'Year-Month' desc;q = limit q 30;

What am I doing wrong?

 

 

#Salesforce Developer

8 réponses
  1. 1 mai 2024, 17:30

    @Chandramouli Ray seems we're back to the syntax error again

     

    Syntax Error at position [line 3: column 64] after token into :: edDate')) into g; q = foreac

    Seems it does not like the into syntax as part of the group line. I sure wish there was some kind of SAQL validator that could be specific as to what the underlying issue is. 

     

    Also thanks for helping me through this

0/9000