I have a SAQL Query which takes a list and attempts to display a total row at the bottom.
However, the way that my code is written is causing the Total column to be alphabetically rearranged so that it falls within the other fields. The data is correct, it's just re-ordered.
q = load "Opportunity_Campaign_Influence";
mainData = group q by ('CampaignId.Type', 'Opp_Probability');
mainData = foreach mainData generate q.'CampaignId.Type' as 'CampaignId.Type', q.'Opp_Probability' as 'Opp_Probability', sum(q.'ARR_Share__c') as 'A';
mainData = order mainData by ('CampaignId.Type' asc, 'Opp_Probability' asc);
totalRow = group mainData by ( 'Opp_Probability');
totalRow = foreach totalRow generate "TOTAL" as 'CampaignId.Type',
mainData.'Opp_Probability' as 'Opp_Probability' ,
sum(mainData.'A') as 'A';
result = union mainData, totalRow;
result = group result by ('CampaignId.Type', 'Opp_Probability');
result = foreach result generate 'CampaignId.Type' as 'CampaignId.Type',
'Opp_Probability' as 'Opp_Probability' ,
sum('A') as 'A';
result = limit result 2000;