Skip to main content
Hi All 

 

I am trying to write code in einstein Analytics but gettting error and below is the code.

 

I am trying to group the value of column with mutiple value into one.

 

For Eg : if the bucket has 0 hour, 0.5 hour, 2 hour, 3 hour, 4 hour and so on i want to group them as 0 to 2 hour 

 

2 to 4 hour 

 

q = load "Register_Case";

 

q = filter q by 'Status' in ["Cancelled", "Customer Deferred", "In Progress", "New", "Not Assigned", "Resolved"];

 

q = group q by ('Region', 'Case_Age__c');

 

q = foreach q generate 'Region' as 'Region', (case when 'Case_Age__c' in ["0 hour(s)","0.5 hours(s)", "1 hour(s)","1.5 hour(s)"] then '0to2 hour' else 'Case_Age__c' end) as 'Case_Age__c', count() as 'count';

 

q = order q by ('Region' asc, 'Case_Age__c' asc);

 

q = limit q 2000;
1 answer
  1. Jan 15, 2019, 4:12 AM
    Hello Kunal,

     

    Can you try the below code: (enclosing 0to2 hour in double quotes instead of single quote)

     

    q = load "Register_Case";

     

    q = filter q by 'Status' in ["Cancelled", "Customer Deferred", "In Progress", "New", "Not Assigned", "Resolved"];

     

    q = group q by ('Region', 'Case_Age__c');

     

    q = foreach q generate 'Region' as 'Region', (case when 'Case_Age__c' in ["0 hour(s)","0.5 hours(s)", "1 hour(s)","1.5 hour(s)"] then "0to2 hour" else 'Case_Age__c' end) as 'Case_Age__c', count() as 'count';

     

    q = order q by ('Region' asc, 'Case_Age__c' asc);

     

    q = limit q 2000;

     

    Best Regards,

     

    Akshay
0/9000