CSL report variables

Medallia Agile Research offers a powerful scripting language called Custom Scripting Language (CSL) to enhance your surveys and reports. You can use it to place variables in your surveys and reports by selecting them from a dropdown.

This article lists the extra variables available in the ReportBuilder. Many of the CSL survey variables can also be used in the ReportBuilder, specifically the survey, questions, and results sections. To see these variables, refer to CSL survey variables.

Report variables.

See the following sections for a list of report variables, details on operators, and examples:

Report variables

VariableDescription
{{report.id}}ID of the report.
{{report.name}}Report name. This is mostly for internal use, but it's also shown in the Report Viewer if no title is specified
{{report.title}}Title of the report viewer.
{{report.language}}Active language of the report.
{{report.filter.name}}Name of the global report filter.
{{report.prebuiltFilter.name}}Name of the selected prebuilt filter. This is only available in the Report Viewer inside elements.

Share variables

VariableDescription
{{share.name}}Name of the share you're accessing. The name refers to the filter of the share

Elements variables

VariableDescription
{{report.elements}}Collection of all the elements in the report. This is used mostly in 'each' loops
{{report.elements.id-123}}Reference to the element with ID 123.
{{element}} Reference to the current element. This is short for: {{report.elements.id-

[current element id]

}}

No matter which way you access your element, the following variables can always be used. We'll describe them using the {{element… prefix, but you safely replace that with {{report.elements.id-123…

VariableDescription
{{element.id}}ID of the report element.
{{element.orderNumber}}Order in which the element appears in the report.
{{element.title}}Title of the element.
{{element.shortName}}Short name, used in the index on the left.
{{element.comment}}Comment of the element. This is the text you can add below the chart.
{{element.data}}Collection of all data sources inside this element. Everything that can be found under the Data tab inside the report builder.
{{element.data.1}}Reference to the first data source of this element.
{{element.data.1.name}}Name of the data source. Either the question caption or metadata name (respondent field or contact field.)
{{element.data.1.question}}Reference to the question of this data source. All question variables can be found in Survey variables.
{{element.data.1.metadata}}Name of the metadata used in this data source (respondent field or contact field).
{{element.data.1.filter.name}}Name of the filter used in this data source.
{{element.statistics}}Collection of the statistics of this element. This is what you can see below the chart if you enable Statistics in the element options.
{{element.statistics.1}}Reference to the first item of the element statistics.
{{element.statistics.1.label}}Text of this stat.
{{element.statistics.1.respondentCount}}Number of respondents for this stat.
{{element.statistics.1.count}}Count for this stat. For most charts, this is equal to the respondent count.
element.statistics.1.avgAverage value for this stat.
element.statistics.1.npsNPS score for this stat.
element.statistics.1.minMinimum value for this stat.
element.statistics.1.maxMaximum value for this stat.
element.statistics.1.sumSum for this stat.
element.statistics.1.medianMedian value for this stat.
element.statistics.1.stdevStandard deviation value for this stat.
element.statistics.1.varVariance for this stat.

Operators

CSL offers a wide range of operators to further customize your reports. See Custom Scripting Language (CSL) for a complete list of CSL operators.

Inside reports, modal windows and tooltips can be useful. See Tooltips, popovers, and modal windows for more examples and information.

Examples

You can combine all these variables and operators to create more advanced logic. Below you can find some ready-to-use CSL code snippets for different situations. Each snippet can be used immediately or you can tailor it to your own specific situation.

More examples can be found in Survey Custom Scripting Language (CSL) snippets.

Example: show text based on results

This example shows how to show different text when your filtered ratings are better or worse than the global (benchmark) ratings.

  1. Select Analyze > Reports. Either make a new report or open an existing report.
  2. Create a Column/bar element for a rating scale or NPS question.
  3. Select the Data tab and apply a filter to this element. You can also apply a global report filter if you prefer.
  4. Select Add > Benchmark. Now your data is ready for the CSL.
  5. Select the Text tab and add the following to the comment field:
    {{#if (lt report.elements.id-123.statistics.1.avg report.elements.id-123.statistics.2.avg)}}
      The score of your department is lower than the company average.  
      Here are some tips and action points to improve your score: ...
    {{else if (gt report.elements.id-123.statistics.1.avg report.elements.id-123.statistics.2.avg)}}
      Your department is doing better than the company average. Way to go!
    {{else}}
      The score of your department is just on the company average, that is to say that you are better than half of the departments!
      However, this also means that you score worse than the other half of the departments. Via the following action points you can be among the best in the company in the future: ...
    {{/if}}
    

These variables all begin with 'report.elements.id-123…'. Replace '123' with the actual report element ID. You can find this ID in the URL when selecting an element.

Now a different message will be shown to respondents based on the results.