Skip to main content
I'm trying to create a multi-dataset SAQL compare table. I have written the following code, and it all works great;

 

 

a = load "SF_Leads_28_07";

b = load "SF_Opportunity_28_07";

a_A = filter a by date('CreatedDate_Year', 'CreatedDate_Month', 'CreatedDate_Day') in ["90 days ago".."current day"];

b_A = filter b by 'StageName' == "Closed Won" && date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in ["90 days ago".."current day"];

result = group a by all full, a_A by all, b by all, b_A by all;

result = foreach result generate count(a_A) as 'A', count(b_A) as 'B';

result = foreach result generate 'A', 'B', B/A*100 as 'C';

result = limit result 2000;

 

But, I'd like to bring the decimal numbers in the CVR down to 2 decimal places. I know you can use the trunc code;

result = foreach result generate trunc(B/A*100,2) as 'C';

 

But I'm not sure how to get it working.

 

Bonus points if we can show the data in C as a percentage!

 

I'm very new to SAQL, so any help would be vastly appreciated!
답변 2개
  1. 2019년 7월 29일 오전 5:15
    Thanks for your reply, Julien!

     

    I was just confused about where to place it, and ended up putting it as;

    result = foreach result generate 'A', 'B', trunc(B/A*100,2) as 'C';

     

     
0/9000