Skip to main content Link Search Menu Expand Document (external link)

Benchmarking and Gamification using Liquid

Below is an example using Liquid to compare a field containing usage to a specific customer account to a field with a calculated average of all the customer accounts to do a benchmark comparison and create the narration for it. The field values are from the datasets provided by the customer.

{% assign u = accountUsage|times:1 %}
{% assign a=  avgUsage|times:1 %}
{% if u  > a %}
    {% assign percentage = u| divided_by:a|times:100|round:0 %}
    Your product usage within SaaS Magic is {{percentage}} above the industry average of companies similar to your size. Congratulations!
{% else %}
    Your product usage within SaaS Magic is below the industry average
    of companies similar to your size.

    Contact your {{"CSM" | cast_pronounce }} for ideas on
    how you can increase your usage in the platform.
{% endif %}

Output:

    Your product usage within SaaS Magic is below the industry average
    of companies similar to your size.

    Contact your CSM for ideas on
    how you can increase your usage in the platform.

Use Case #1

A customer wanted the narrative for their product usage to dynamically point out to the customer either a positve or negative outcome based on their current usage vs. their usage from the previous quarter. The snippet analysis_usage_determination was created to accomplish this. The Liquid code in the snippet compares the field that contains customers’ average from the previous quarter, analysis_prev_qtr_avg, to the field that contains the average in the current quarter, analysis_current_qtr_avg. The narration shown to the customer is based on whether their usage in the current quarter increased, decreased, or stayed the same. Liquid is used to calculate the percentage increase or decrease of usage to be shown in narration.

{% comment %}
Narration for Analyis scene. There are 3 branches: neutral, positive, and negative.
{% endcomment %}

{% assign analysis_current_qtr_avg = analysis_current_qtr_avg | times:1.0 %}
{% assign analysis_prev_qtr_avg = analysis_prev_qtr_avg | times:1.0 %}

{%- if analysis_current_qtr_avg > analysis_prev_qtr_avg -%}

Compared to the previous three month period, your monthly average increased by --up--{{analysis_current_qtr_avg|minus:analysis_prev_qtr_avg|divided_by:analysis_current_qtr_avg|times:100|ceil|abs}}%. This was awesome to see!

{%- elsif analysis_current_qtr_avg < analysis_prev_qtr_avg -%}

However, your average monthly usage decreased from the previous three month period by {{analysis_prev_qtr_avg|minus:analysis_current_qtr_avg|divided_by:analysis_prev_qtr_avg|times:100|ceil|abs}}%.

{%- elsif analysis_current_qtr_avg == analysis_prev_qtr_avg -%}

This usage level is consistent with the previous three month period as well!
{%- endif%}

The snippet is inserted in the narration box in a slide. The text the snippet generates is shown under the box. The example below is a customer whose usage increased compared to the previous quarter.

The example below is a customer whose usage decreased compared to the previous quarter. Notice in both examples that all you have to do is create the snippet and the narrative text shown to the customer will change based on their data.

Use Case #2

A customer wanted the product usage narration to point out to the customer the amount of storage they used and the percentage used relative to their total subscripton. The snippet LeastPercentageUsed0to10 calculates the percentage used.

{% comment %}
This snippet calculates the percentage used of the lowest usage accounts
{% endcomment %}

{%assign LicenseUsage0to10LeastUsed = LicenseUsage0to10Least|times:1%}
{%assign LicenseUsage0to10LeastReserve = LicenseUsage0to10LeastReserve|times:1%}

{%assign percentageUsed = LicenseUsage0to10LeastUsed|divided_by:LicenseUsage0to10LeastReserve|times:100%}

{{percentageUsed|round:2}}

You can insert Liquid code in the narration box as well as snippets to generate the text you want. Below is an example of using the snippet LeastPercentageUsed0to10 in the narration box as well as other Liquid code. if-endif block is used to check if the perentage that is calculated by the snippet is greater than 1, and if so use the round filter to display the percenatage with no decimals. The custom cast_footnote filter is used so that the contract name won’t be read by the bot, but it willl be displayed in the narration. The append filter is used to add the ‘%’ and ‘TiBs’ to the respective text.

The text that is generated from the snippet and Liquid is code shown under the box.

Here is the complete Liquid code used in the narration box.

{%assign LeastPercentageUsed0to10 = LeastPercentageUsed0to10|times:1%}

{% if LeastPercentageUsed0to10 >= 1%}
{%assign LeastPercentageUsed0to10 = LeastPercentageUsed0to10|round%}
{% endif %}

This site{{ LicenseUsage0to10LeastLabel | cast_footnote }} used only {{ LicenseUsage0to10Least | cast_highlight }} {{ "TiBs" | cast_pronounce|cast_highlight }} during this period, which is {{LeastPercentageUsed0to10|append:"%"| cast_highlight }} of the reserved capacity available.