0
Region Sector Notes Count of Rows
America FI Client Choice 2
Entry 8
**Sub Total 10**
MI Rotation 45
Data Source 30
**Sub Total 75**
**Sub Total 85**

I have the above table which shows Sub Total by Notes and Sub Total by Region. I want to write a SAQL query in which I could see just "SUB TOTAL BY REGION" in the final output in compare table. (example just I want to see Sub Total as 85 in the output table)

4
  • 1
    Hey, have you made an attempt to write this SAQL query? Or have you just got a requirement and want someone from Salesforce Stack Exchange to implement it for you? Sorry to say, but this is not the idea of this site. Mar 17, 2022 at 17:26
  • @FelixvanHove yes, I have implemented it. Mar 18, 2022 at 9:34
  • q = load "Issuance1"; q = group q by rollup ('Region','Sector','SalesComments'); q = foreach q generate case when grouping('Region') == 1 then "Total" else 'Region' end as 'Region', case when grouping('Sector') == 1 then "Subtotal" else 'Sector' end as 'Sector', case when grouping('SalesComments') == 1 then "" else 'SalesComments' end as 'SalesComments', count() as 'count'; q = order q by ('Region' asc, 'Sector' asc,'SalesComments' asc); q = limit q 2000; Mar 18, 2022 at 9:34
  • But the above query doesn't give me the right output Mar 18, 2022 at 9:35

1 Answer 1

0
q = load "Issuance1";
q = group q by rollup ('Region','Sector','SalesComments');
q = foreach q generate case when grouping('Region') == 1 then "Total" else 'Region' end as 'Region', 
case when grouping('Sector') == 1 then "Subtotal" else 'Sector' end as 'Sector',
case when grouping('SalesComments') == 1 then "" else 'SalesComments' end as 'SalesComments',
count() as 'count';
q = filter q by ('SalesComments' != "" or 'Sector' =="Subtotal");
q = filter q by 'Region' != "Total";
q = order q by ('Region' asc, 'Sector' asc,'SalesComments' asc);
q = limit q 2000;

This is the answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .