Toucan 3.0
YouPrep documentationHelp centerGet a demo
  • Welcome
    • 👋Welcome to Toucan
    • ⚙️Technical resources
      • ⚙️Toucan stack
      • Setup mode
        • Toucan SaaS mode
      • ⚙️Security
        • Application Security
        • Source Code Quality
        • Global Security Practices
        • Security of Docker Images
  • TUTORIALS
    • 📊Getting Started : Embedded Analytics
    • 🤓Advanced tutorials
      • Embedding a story with user attributes
        • Dynamic filter with user attributes
        • Dynamic Tables
        • Dynamic Database
        • Dynamic Host
      • Using the HTTP API connector in advanced use cases
      • Using advanced syntax for SQL queries
      • Merging filters with our tool
      • Deep customization chart (CSS)
        • Homepage customization
        • Chart customization
        • Dashboard customization
  • Data Management
    • 🧮Overview of Data In Toucan
    • 📡Datasources in Toucan
      • 🔌Managing Connectors
        • 🔌Creating, editing and deleting a connector
        • 🔌Set up OAuth2 credentials for your platform
        • 🔌Setting up a connector
          • 🔌Generic Connectors
            • 🔌Setting up an HTTP API connector
            • 🔌Setting up an ODBC Connector
          • 🔌Database and data warehouse Connectors
            • 🔌Setting up an AWS Redshift Connector
            • 🔌Setting up a Snowflake Connector
            • 🔌Setting up a PostgreSQL Connector
            • 🔌Setting up a Google Big Query Connector
            • 🔌Setting up an AWS Athena connector
            • 🔌Setting up a MySQL connector
            • 🔌Setting up a MongoDB connector
            • 🔌Setting up a Microsoft SQL Server connector
            • 🔌Setting up an Azure SQL connector
            • 🔌Setting a Databricks Connector
            • 🔌Setting up a ElasticSearch Connector
            • 🔌Setting up a Clickhouse Connector
          • 🔌Online services connectors
            • 🔌Setting up a Sharepoint Connector
            • 🔌Setting up a Google Sheets Connector
            • 🔌Setting up a Salesforce Connector
            • 🔌Setting up a Hubspot Connector
          • 🔌Setting up an AWS S3 connector
      • 🗄️Managing remote file storages
        • 🗂️Setting up a file storage
          • SFTP
        • 📄Create a dataset from a file
      • 📁Managing Files
        • 📁Adding, editing and deleting local files
        • 📂Using advanced file settings
        • 📁Adding and combining remote files in Toucan
    • 🔢Datasets in Toucan
      • 🔢Stored and Live Datasets
      • 💿Managing datasets
        • 🔢Creating datasets
        • 🔢Editing, Duplicating and Deleting a dataset
        • 🔢Refreshing and Publishing Datasets
        • 📈Optimize data performance
        • 🗂️Adding indexes to stored datasets
        • 👩‍💻Code mode and single mode
      • 🛑Setting permissions on dataset
      • 🗃️Maintaining Data
        • 🗃️Tagging datasets
        • 🗃️Identifying datasets dependencies
        • 🗃️Set validation rules
    • 🧑‍🍳Preparing data
      • Overview of YouPrep™
        • 🎹Column header
          • Rename column
          • Duplicate column
          • Fill null values
          • Replace values
          • Sort values
          • Convert columns data types
        • Add
          • Add text column
          • Add formula column
          • Add conditional column
        • Filter
          • Delete columns
          • Keep columns
          • Filter rows
          • Top N rows
          • ArgMax
          • ArgMin
        • Aggregate
          • Group by
          • Add total rows
          • Hierarchical rollup
          • Get unique groups/values
        • Compute
          • Compute evolution
          • Cumulated sum
          • Percentage of total
          • Rank
          • Moving average
          • Compute statistics
          • Absolute value
        • Text
          • Concatenate
          • Split column
          • Extract substring
          • To lowercase
          • To uppercase
          • Compare text columns
          • Trim spaces
          • Replace text
        • Date
          • Convert text to date
          • Convert date to text
          • Extract date information
          • Add missing dates
          • Compute duration
          • Normalize date granularity
        • Reshape
          • Pivot
          • Unpivot
          • Waterfall
        • Combine
          • Append datasets
          • Join datasets
        • Geo
          • Geographic dissolve
          • Geographic hierarchy
          • Geographic simplify
          • Prepare geo data (with basemap)
      • YouPrep™ Native SQL
      • Hybrid pipeline
    • ➿Managing variables in Toucan
      • ➿Variables hub
      • ♈Use variables in YouPrep™
      • ➿Easy reference to variables
    • 🧞Using advanced data concepts
      • 🧞Data personnalisation with user attributes
        • Connector setup with a user attribute
        • Database selection with a user attribute
        • YouPrep data filtering with a user attribute
        • Filter data in SQL with a user attribute
      • 🧞Advanced syntax for variables
      • 🧞Data cache
  • Visualizations and Layouts
    • 📺Apps
      • 📺Managing Apps
        • ➕Creating Apps
        • 📄Duplicating Apps
        • 🖨️Publishing Apps
        • 🚮Deleting Apps
        • ✍️Editing within an App
      • 🖌️Customizing Apps
        • Customizing chart color elements
        • Customizing the app's font
        • Adding Assets
        • Adding Glossary
        • Setting up, Managing and testing custom visibilities
        • Customizing the "no data error" message
        • Creating a dynamic background based on an Filter's column
      • 🏠Home
        • Creating the Home
        • Creating Tiles
          • Tile Dynamic Value
          • Tile Leaderboard
          • Tile Line
          • Tile Scorecard
          • Tile Bullet
          • Tile Heatmap
          • Tile PDF
          • Tile Video
          • Tile Image
          • Tile Text
          • Tile HTML
          • Tile Separator
      • ✨Stories
        • Creating a Story
        • KPIs
        • Narrative
        • Crossfilter
      • 📽️Filters
        • Managing Filters
          • Creating, reusing and editing Filters
          • Applying Filters
          • Unpinning and deleting Filters
        • Type of Filters
          • Dropdown
          • Checkboxes
          • Buttons
          • Date Range
          • Hierarchical
          • Slider
        • Templating from Filters' values
        • Dependant Filters
      • 📈PDF Report
      • 🎡Datawall
      • 🏗️Dashboard Builder
        • Create a Dashboard Builder
        • Embed a Dashboard Builder
        • Dashboard export options
      • 🌟MyFavorites
    • 📊Creating Visualizations
      • 🤩Viz Gallery
        • ✨New Viz Designs
          • Barchart
          • Barlinechart
          • Bubblechart
          • Circularchart
          • Heatmap
          • Leaderboard
          • Linechart
          • Stacked Barchart
          • Tablechart
        • 📁Legacy Viz Designs
          • Bulletchart
          • Funnelchart
          • Gantt chart
          • HTML
          • Leaderboard Centered Average
          • Mapchart
            • Configure a drill
          • Mediachart
          • Radarchart
          • Timeline
          • Versuschart
          • Waterfallchart
          • Score Card
      • 🧠Common Chart Configuration
      • 💅Customizing chart colors
      • 🧞‍♂️Advanced chart configuration
        • Templating from chart's dataset
        • Add units, precisions and sentiments
        • Adding Tutorials
        • Add sparklines
        • Navigate with stories
        • Group informations in your stories
        • Multiple Charts in One Story
        • Manage dates
        • Customize tiles' sources
        • Add stars to tiles' title
        • Manage data order in your tiles
        • Navigate with tiles
    • 👩‍💻Embedding
      • 🔐Authentication
      • 🖇️Integration
        • Generate and manage embeds
        • Customize embeds
        • Embedding a Toucan App Using iFrames
        • Passing Extra Variables to Your Toucan Embed
      • ⚙️Embed SDK
        • Embed SDK Authentication
      • ❓FAQ
    • 🙋Self-Service
      • Self-Service Dashboard
        • The embedded Self-Service Dashboard
        • The in-platform Self-Service Dashboard
      • Self-service PDF Report
  • Collaboration
    • ⏰Creating alerts
    • 📧Managing notifications
    • ➕Enriching a story with descriptions
    • 💌Sharing content
    • 💬Adding comments to stories
  • Administration
    • ⚙️Instance Management
      • ⚙️Managing operations in SaaS
      • ⚙️Customizing your instance (whitelabel)
    • 👥Managing Users
      • 👥Users
      • 👥Managing user groups
      • 👥Managing user properties
      • 👥Setting up permissions and visibilities
    • 🌐Managing languages in Toucan (internationalisation)
    • 📈Monitoring Engagement with User Analytics
      • 🎛️How to Filter your User Analytics?
      • 🖥️Understanding your User Analytics Dashboards
  • Additional Ressources
    • 📚External documentation
    • 🚁Support for App-builders
    • 🆕Latest releases
      • 🎁2025 Releases
      • 🎁2024 Releases
      • 🎁2023 Releases
    • 🔧Troubleshooting
      • Troubleshoot:: DataHub
      • Cross-Site Cookies
      • How to :: read the inspector error
      • How to :: troubleshoot the toucan way
Powered by GitBook
On this page
  • What’s the difference between ‘{{ }}’ & ‘<%= %>’ syntaxes?
  • Filters
  • User attributes
  • Extra Variables
  • Language Variables
  • Chart Data
  • User Group
  • Relative Dates

Was this helpful?

  1. Data Management
  2. Using advanced data concepts

Advanced syntax for variables

What’s the difference between ‘{{ }}’ & ‘<%= %>’ syntaxes?

Variable values to be interpolated can be injected from 2 different sources:

  • The user interface (front-end): these are variables that could be set by the App-builder and/or Viewer when editing the app configuration through the studio or when dealing with filters. These kinds of variables are injected by using the '<%= ... %>' syntax. This syntax is executed as Javascript code.

  • Toucan's backend: these are variables coming from Toucan's instance configuration (for example instance name), or the user's attributes. These kind of variables are injected by using the {{ ... }} syntax.

Filters

In some configuration interfaces, you might need to use manually use our syntax to refer to a filter value, for a more advanced usage. This can be done with the syntax below (the FILTER_ID is accessible within the filter's configuration interface).

<%= filters["FILTER_ID"]["COLUMN_NAME"] %>

More detail on templating from the filter's value here.

All option in filters (__VOID__)

By default, the filters created are using the "All" option that allows to not apply the filtering. All option refers to the variable value "__VOID__" used as a kind of identifier to not apply the filter when the variable is used in YouPrep.

The case of date range filters

Date Range filters are special as when we choose the dataset's column, it's not from where we're fetching data. Also, as a range, it exposes a start and end date. Here's how to use them:

Start:

<%= filters["FILTER_ID"]["start"] %>

End:

<%= filters["FILTER_ID"]["end"] %>

Advanced use date of date filters

Variable from data range filters are expressed within ISO-8601 format with date and time as the following date: 2023-02-02T00:00:00.000Z

For different cases (data querying, display, ...), you might only need the date part (2023-02-02).

In order to extract the date part, you can use the templating syntax below (example for start date):

<%= filters["FILTER_ID"]["start"].toISOString().split('T')[0] %>

Advanced use case with management of __VOID__ in SQL

For some advanced use cases, when creating a dataset from a connector, you can make the choice to make some data transformation/filtering directly into SQL and refer to the variable with the syntax above. However, when the filter uses the option "All", the variable will take the value "__VOID__" that won't be interpreted by your database. Thus, you might condition the application of the filter.

Here is an example (where 4171d27a-f8dc-4c91-8c43-c750aa1eee95 is corresponding to the filter's ID, and company to the column name used by the filter) of a complete SQL query that includes WHERE conditions in order to filter the data.

SELECT * from my_table WHERE 
CASE
    WHEN <%= filters["4171d27a-f8dc-4c91-8c43-c750aa1eee95"]["company"] %> = '__VOID__' 
        THEN true
    ELSE
        company = <%= filters["4171d27a-f8dc-4c91-8c43-c750aa1eee95"]["company"] %>
END

Advanced use case with management of __VOID__ in storytelling

When being within the storytelling part, you can refer to the filter value (within narrative, section title, text tile, ...) in order to personalize the experience and facilitate informations interpretation. However the the actual selected value is corresponding to __VOID__ , you might want to display a more meaningful label. This can be done with the syntax below:

<%= filters["FILTER_ID"]["COLUMN_NAME"] === 'VOID' ? 'label_for_All' : filters["FILTER_ID"]["COLUMN_NAME"] %>

Advanced use case of list

Depending the the configuration of the filter, it can retrieve a list of values (for example the "checkbox" type) and not just one value. Thus in order to display the value in a customized way, the function join can be used in order to separate each value of the list by a custom char:

<%= filters["4171d27a-f8dc-4c91-8c43-c750aa1eee95"]["companies"].join(', ' ) %>

User attributes

At different configuration interfaces (connector settings, query setting, YouPrep, ...) you get to refer to user attributes, in order to personalize the experience depending on the user. In the example below, we refer to the user attribute named "database_name_attribute"?

{{ user.attributes.database_name_attribute }}

In some cases, we need to use a more complex syntax, in order to use a default value when the user attribute doesn't exist. In the example above, the syntax is referring to a user attribute named "database_name_attribute", and uses by default 'database_name_default' if the user attribute doesn't exist.

{{ (user or {}).get('attributes', {}).get('database_name_attribute', 'database_name_default') }}

Note that, if you want to display the value of a user attribute, within a narrative, tile, or home section title, you must use the <%= ... %> syntax like in the example (with country variable) below:

<%= user["attributes"]["country"] %>

Extra Variables

Extra Variables correspond to variables coming from an external environment (sent through Toucan SDK). You can refer to an extra variable by using the syntax below.

<%= extraVariables["my_variable"] %>

In some cases, we need to use a more complex syntax, in order to use a default value when the extraVariable doesn't exist within the context. In the example below, we refer to the extraVariable 'my_variable' if it exists, else we use by default the value 'my_default_value'.

<%= extraVariables["my_variable"] ?? 'my_default_value' %>

Language Variables

At different levels of the app (YouPrep, narrative, titles, ...), you can refer to language variables in order to personalize the end-user experience according the language preference. You can refer to a variable (defined in the dictionary of translation) with the syntax below:

<%= lang["ELEMENT_TO_TRANSLATE"] %>

You can also refer to the variable containing the value of the language preference with the syntax below:

<%= locale %>

More detail on language and translation here.

Chart Data

When being in a story, it's possible to refer to the first value of a specific column in the data used by the chart, for example in order to give contextualized data within your narrative. This can be done with the syntax below (knowing that the content between data brackets corresponds to the chart ID, which can be found in the chart configuration interface).

<$= data["4c7274d9-bae4-e77c-d1ef-21ddd98dee0c"]["my_column"] $>

However, when referring to a column resulting from an aggregation made through the SmartEditor, the column ("my_column") to which you have to refer to follows this format: __aggregType_myColumn__.

So for example, when referring to a column "profit" aggregated with the sum operator, the syntax to use will be:

<$= data["4c7274d9-bae4-e77c-d1ef-21ddd98dee0c"]["__sum_profit__"] $>

Here is the list of the different aggregation prefixes: sum (for sum), avg (for average), min (for minimum), max (for maximum), first (for first), last (for last), count (for count), count distinct (for Count Distinct).

More detail on chart dataset templating here.

User Group

At different configuration interfaces (connector settings, query setting, YouPrep, ...) you can refer to user attributes, in order to personalize the experience depending on the user. The example below shows how to call the variable through the back-templating syntax.

{{ user.groups }}

Note that, if you want to display the value of a user attribute, within a narrative, tile or home section title, you must use the <%= ... %> syntax like in the example (with country variable) below:

<%= user["groups"] %>

Syntax to use depending on the location:

  • {{ ... }} : connector, connector query

  • <%= ... %> : narrative, tiles

The user variable "groups" retrieves a list of values (groups)

Relative Dates

You can refer to relative dates defined automatically within Toucan. Here is the list of available variable.

  • Today: <%= dates.today %>

  • Yesterday: <%= dates.yesterday %>

  • The actual week monday: <%= dates.thisWeekMonday %>

  • The last week monday: <%= dates.lastWeekMonday %>

  • The first day of the month: <%= dates.thisMonth %>

  • The first day of the last month: <%= dates.lastMonth %>

  • The first day of this quarter: <%= dates.thisQuarter %>

  • The first day of the last quarter: <%= dates.lastQuarter %>

  • The first day of this semester: <%= dates.thisSemester %>

  • The first day of the last semester: <%= dates.lastSemester %>

  • The first day of the year: <%= dates.thisYear %>

  • The first day of the last year: <%= dates.lastYear %>

You can easily refer to those variables within YouPrep without using any syntax. More about it here.

Last updated 10 months ago

Was this helpful?

🧞
🧞