You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Customizing Wave Analytics Dashboards Using SAQL


By: Santhosh

The SAQL is used to customize the dashboard in Wave Analytics. When a dashboard loads in a browser, at the same time the JSON file always runs in background. The combination of steps and widgets are called Dashboard JSON. Before the Dashboard JSON hits the server, a translation is done from compact format into SAQL Queries format.

Both incoming and outgoing results from or to the Server is always in the JSON file format.

For Example, take an opportunity product object and opportunity type filed for grouping process. Here, we can reduce the row limit from three to one using SAQL.

SAQL  

  • In Analytics Cloud, SAQL stands for Salesforce Analytics Query Language used for accessing the data from dataset.
  • The following are analytic cloud components that use the SAQL in the background.
  1. Lenses
  1. Dashboards

Dashboard JSON 

  • Dashboard is used to visualize the data from the dataset that is to represent the data in the pictorial format for better understanding.
  • Dashboard is made up of charts, metrics, tables, etc.
  • Dashboard JSON is a file runs in a background of lens and dashboard.
  • The dashboard JSON is a combination of Steps and Widgets.

 

Install the SAQL Plugin 

Search ‘Salesforce Analytics cloud SAQL tester’ in Google.

customizing wave analytics

 

  • Drag and drop Salesforce Analytics cloud SAQL tester into Bookmark bar inside the active analytic cloud Logged in tab in a browser.
  • This Salesforce Analytics cloud SAQL tester doesn’t work outside of analytic cloud tab.

SAQL Syntax 

Example SAQL code for understanding the basic syntax:

q = load “0Fb28000000XlJdCAK/0Fc28000000YT1OCAW”; // loads the data from dataset with id.

q = group q by ‘Opportunity.Type’; // used for grouping the Opportunity Type field

q = foreach q generate ‘Opportunity.Type’ as ‘Opportunity.Type’, count() as ‘count’;

\\ generates keyword to display column in a table & as/alias used to display the column name for our convenience & This generate keyword is similar to Select keyword in SQL.

q = limit q 2000; \\ used to reduce the length of row when row displayed in the dashboard.

 

Steps to customize the dashboard Using SAQL: 

Step 1: 

  • Open the Product Opportunity dataset which was already created in Wave Analytics(App).
  • Now,  the Opportunity lens opened, then right click on the mouse[Symbol]Select ‘Inspect’[Symbol]Click on Network Tab[Symbol]Enter ‘remote’ keyword in Filter box.
  • Now, Group the field (Opportunity Type) by using Group by option available in Lens.

 

customizing wave analytics

Step 2: 

  • After the opportunity type field is grouped, the traffic between the client and server recorded in this remote section.
  • Click on the remote [Symbol] Select Header tab [Symbol] Under Request Payload section select View Source and then copy and paste the SAQL came from server.

 

customizing wave analytics

Step 3: 

  • The following page will display,  when Salesforce Analytics cloud SAQL tester bookmark link is clicked.

customizing wave analytics

Step 4: 

  • Now, paste the SAQL into this INPUT box; then the corresponding output will be displayed when send button is cliked. This is only for testing how the SAQL works in the background.

customizing wave analytics

Step 5: 

  • Save the lens with appropriate values and click on the Clip to designer option; then it will automatically go to Dashboard.

wave analytics salesforce

Step 6: 

  • The previously created lens is available in dashboard. Click on Chart and Double click on Lens (Opportunity Product Lens) [Symbol]Save the dashboard.

wave analytics salesforce

Step 7: 

  • Press CTRL + E in the keyboard and the JSON editor will display which JSON File. We need to add SAQL code inside the Query section.

wave analytics salesforce

Step 8: Add the following code into pigql(Pig Query Language) equals to SAQL (Salesforce Analytics Query Language).

q = load \"products_opportunities\";  

q = group q by 'Opportunity.Type';  

q = foreach q generate 'Opportunity.Type' as 'Opportunity.Type', count() as 'count';  

q = limit q 1;
  • The SAQL performs the functionality beyond the work done by configuration.
  • Pigql query must be added start and end of the query scope.
  • Click the Switch to Runtime button to proceed the modification done in JSON file.
  • If you click the Reload JSON, it will undo the modification done in JSON file.

 

wave analytics salesforce

 

Please refer the following link for more information:

https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_json.meta/bi_dev_guide_json/bi_dbjson_intro.htm

Step 9: 

  • Now the row count will be decreased from three to one. This is the power of SAQL that even has compact form inside query section.

wave analytics salesforce

Conclusion: 

  • Finally, the dashboard is modified with the help of SAQL in JSON file.
  • We can restrict the row length or any other modification like grouping filtering and measuring etc.
  • We can display maximum 2000 rows in a single dashboard.
  • SAQL is the highest priority than compact form.