You can have that in select clause and use the new field in order by clause something like this:- q = load "Opportunity_Pipeline_Data2"; q = filter q by 'StageName' in ["Closed Lost", "Stage 7"]; q = filter q by 'Account_Type__c' == "Prospect"; q = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["2 quarters ago".."1 quarter ahead"]; q = group q by ('CloseDate_Month', 'StageName'); q = foreach q generate case when ('CloseDate_Month' in ["01"]) then "Jan" when ('CloseDate_Month' in ["02"]) then "Feb" when ('CloseDate_Month' in ["03"]) then "Mar" when ('CloseDate_Month' in ["04"]) then "Apr" when ('CloseDate_Month' in ["05"]) then "May" when ('CloseDate_Month' in ["06"]) then "Jun" when ('CloseDate_Month' in ["07"]) then "Jul" when ('CloseDate_Month' in ["08"]) then "Aug" when ('CloseDate_Month' in ["09"]) then "Sep" when ('CloseDate_Month' in ["10"]) then "Oct" when ('CloseDate_Month' in ["11"]) then "Nov" when ('CloseDate_Month' in ["12"]) then "Dec" else "N/A" end as 'CloseDate_Month', 'StageName' as 'StageName', sum('Amount') as 'sum_Amount'; q = foreach q generate case when (write case stetment here end as 'CloseDate_Month2'; q = order q , 'CloseDate_Month2','StageName' asc); q = limit q 2000
q = load "Opportunity_Pipeline_Data2";
q = filter q by 'StageName' in ["Closed Lost", "Stage 7"];
q = filter q by 'Account_Type__c' == "Prospect";
q = filter q by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["2 quarters ago".."1 quarter ahead"];
q = group q by ('CloseDate_Month', 'StageName');
q = foreach q generate case when ('CloseDate_Month' in ["01"]) then "Jan" when ('CloseDate_Month' in ["02"]) then "Feb" when ('CloseDate_Month' in ["03"]) then "Mar" when ('CloseDate_Month' in ["04"]) then "Apr" when ('CloseDate_Month' in ["05"]) then "May" when ('CloseDate_Month' in ["06"]) then "Jun" when ('CloseDate_Month' in ["07"]) then "Jul" when ('CloseDate_Month' in ["08"]) then "Aug" when ('CloseDate_Month' in ["09"]) then "Sep" when ('CloseDate_Month' in ["10"]) then "Oct" when ('CloseDate_Month' in ["11"]) then "Nov" when ('CloseDate_Month' in ["12"]) then "Dec" else "N/A" end as 'CloseDate_Month', 'StageName' as 'StageName', sum('Amount') as 'sum_Amount';
q = foreach q generate case when (write case stetment here end as 'CloseDate_Month2';
q = order q , 'CloseDate_Month2','StageName' asc);
q = limit q 2000