how to create a bucket field, percentage in wave

Currently I have a dataset that is all opportunities.

I generated a dashboard and in there I have report/graph that is all the opportunities grouped by a field called channel__c

In salesforce I would have created a summary report and group by channel and then add formula field, that will look like this

``````RowCount / PARENTGROUPVAL(RowCount, GRAND_SUMMARY)
``````

However in wave I dont see this option, I am wondering is there a point and click like traditional salesforce report to do this or I need to add SAQL?

I have also try ammending my SAQL but I havent been able to get it right, as i keep getting an error: Unknown IDTOKEN: t

``````q = load "Opportunities";
q = group q by 'Channel__c';
t = foreach q generate count() as 't';
q = foreach q generate 'Channel__c' as 'Channel__c', count() as 'channelcount';
q = foreach q generate 'Channel__c' as 'Channel__c', channelcount/t as 'Count';
q = order q by 'Channel__c' asc;
q = limit q 2000;
``````

I would use a windowing function to get the count for each channel divided by the total. Below is the sample code.

``````q = load "Opportunities";
q = group q by 'Channel__c';
q = foreach q generate 'Channel__c' as 'Channel__c', count() as 'channelcount', sum(count()) over([..] partition by 'all') as 't';
q = foreach q generate 'Channel__c' as 'Channel__c', ('channelcount'/'t') as 'Count';
q = order q by 'Channel__c' asc;
q = limit q 2000;
``````
• thank you for Widiwing funciton docs it has more sense with your sample code, luckuly I found a simpler way to do it, i will be posting the answer with all the steps as it might benefit other people – manza Jan 2 '18 at 23:23

I was able to find a way without going into direct SAQL: The first thing to do is changing the bar chart into a campare table (at the end we convert the table back into bar chart):

Then we need to add a new column into the table, for my example I have pick count of rows again:

Then we need to edit the particular column from number to percentage:

The edit option shows on the right side:

For this case i used percentage of the group, I click apply and then done.