BookmarkSubscribeRSS Feed

Using parameters with Data-Driven Content in SAS Visual Analytics

Started ‎12-04-2019 by
Modified ‎12-05-2019 by
Views 5,835

When Data-Driven Content (DDC) object was first added to SAS Visual Analytics (version 8.2), I wrote a two-part article to explain the concept and help introduce its basics. At that time, we explored the key elements that are provided in the json message that the DDC receives from the SAS Visual Analytics report: resultName, data, and columns. Intentionally, I didn’t include parameters, but now that people have adventured through Data-Driven Content, I started to get questions about accessing parameters and their values from the DDC Java Script code.

 

Information about parameters can be found in the json message and its structure is very similar to columns, but the parameters element isn’t always present in the message.

 

01-Structure of the message received from VA with parameters01-Structure of the message received from VA with parameters

The parameters element is optional, and it only shows up in the message if there is a parameter used by the Data-Driven Content object, for example:

  • A calculated item or aggregated measure that uses a parameter in its expression (e.g. pDiscountPct) is assigned to the DDC Roles pane

02-Calculated item expression with parameter02-Calculated item expression with parameter

  • The DDC has an advanced filter which expression is based on a parameter (e.g. pTypeMultiple)

03-Filter expression with parameter03-Filter expression with parameter

  • The DDC has a rank and the rank definition depends on a parameter (e.g. pTopN)

04-Rank definition with parameter04-Rank definition with parameter

For each parameter added to the message, you will get at least its name (internal id), label, datatype, and value. The value can be a single value or an array, if the parameter accepts multiple values. This is an example of a parameter called “pTypeMultiple” that has three string values assigned to it:05-Example of multi-value parameter05-Example of multi-value parameterIf a parameter is formatted, the format information is included. The example below shows a parameter “pDiscountPct” with a value of 18%:

 

06-Example of parameter with format06-Example of parameter with format

You saw previously that parameters must be used by the DDC object (in calculation, filter, or rank) for them to be added to the json message. What if you still want to have access to parameters and their values, but the parameter is not used in any calculation, filter, or rank? The answer is simple: you will have to add one of those elements, even if you don’t really need them. For example, you can add a dummy advanced filter that returns true always, so it won’t affect the results, such as:

07-Dummy advanced filter using a parameter07-Dummy advanced filter using a parameter

If you want to play around with parameters in DDC, I highly recommend you try the sample DDC available in GitHub called jsonDataViewer.html. This sample DDC displays the json message and it makes it easier to visualize what’s being passed from VA to the DDC object. The easiest way to use the sample is to add the URL below to the Options pane of your DDC object:


https://sassoftware.github.io/sas-visualanalytics-thirdpartyvisualizations/samples/jsonDataViewer.ht...

 

The video below contains an example of a DDC with calculated item, rank, and filter.

 

 

If you want to explore this example in your environment, I've attached the CARS dataset that should be loaded in the Public CAS library and the report as a json file that you can import from SAS Environment Manager (menu option Manage Environment).

Version history
Last update:
‎12-05-2019 09:49 AM
Updated by:

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags