Workbook Controls in the URL
In Sigma you can update the values of workbook controls via URLs. For each type of control there are different formats to add into the URL.
Example
When no controls are included a workbook URL the workbook uses the published workbook's selected control values and displays a URL like this:
https://app.sigmacomputing.com/embed/7ufGXlEsaTB39TSiUUkXIY
If we add a new value (2016) to Year, the URL becomes:
https://app.sigmacomputing.com/embed/7ufGXlEsaTB39TSiUUkXIY?Year=2016
?Year=2016 was appended to the end of the URL as a search parameter. This control targets all three data elements on the page, and as result each element updates to only show data from 2016.
Need to include multiple parameters and values? Simply append an "&" in between like this:
?Year=2016&Region=West,Southwest
Generate a URL
There are times when you may want to generate a URL directly rather than copying from the address bar. To do that, follow the steps below.
- Open settings for the control you want to update through the URL.
Note the Control ID and the Control Type.
The Control ID will be used to identify which control you want to update the value of. The Control type will help determine what format the value needs to be in. - Format the value.
In this step, we'll format the controls and values to be URL encoded. Certain characters can't be present in URLs, so we'll replace them with codes as needed. If your Control ID or control values include spaces, commas, question marks or other characters like that, it will need to be encoded.
Control Type |
Type(s) |
Format |
Example |
Comment |
---|---|---|---|---|
Textbox |
-Text -Number |
encodeURIComponent(<control_id>)= |
|
<control_id> is Customer Id <control_value> is merchant 1 |
Date Picker |
Datetime |
encodeURIComponent(<control_id>)=<control_value> |
|
<control_value> is the ISO Date (without Z) Example 1
Example 2
|
Date Range |
Datetime |
encodeURIComponent(<control_id>)=min:<min_date>, |
|
Where <min_date>/<max_date> is an exact date (ISO Date) or a relative date (<date_type>_<date_unit>_<date_number> Example 1
Example 2
Example 3
|
Value List |
-Text -Number |
encodeURIComponent(<control_id>)= |
|
Values is a list of comma separated URL encoded values. There can be as many values as you want. Example 1
Example 2
|
Value List |
Datetime |
encodeURIComponent(<control_id>)= |
|
Values are comma separated ISO Date (No URL encoding for values) |
Number Range |
Number |
encodeURIComponent(<control_id>)=min:<min_value>, |
|
Example 1 means any value greater than 4000.5 Example 2 means any value between 4000.5 to 5000 |
Checkbox & Switch |
Logical |
encodeURIComponent(<control_id>)=true,false |
|
|
Simple Textbox Example
This is the most basic control in Sigma. Where the control is just a single value. Let’s update the control below to have the value merchant 1.
Looking from the Control Format above. We know that the URL encoding is.
encodeURIComponent(<control_id>)=encodeURIComponent(<control_value>)
control_id is the id found in Step 1. While control_value is the value you want.
After encoding it into the URL, it should look like this
Customer%20Id=merchant%201
Because the Id and the value had spaces in between we had to encode it to be URL safe which is where the %20 comes from.
Date Range Details
Format is in
encodeURIComponent(<control_id>)=min:<min_date>,max:<max_date>
Where min_date / max_date is an exact date (ISO Date) or relative date (in the format <date_type>_<date_unit>_<date_number>)
-
date_type is prior for the past or next for future
-
date_unit can be minute, hour, day, week, month, quarter, or year
-
date_number is a numeric value
Analysis%20Time%20Frame=min:2020-04-01,max:next-day-7
means that the min date on 2020-04-01 to 7 days in the future. Note if the <min_date> or <max_date> is empty it means there isn’t a date set.
Analysis%20Time%20Frame=min:2020-04-01,max:
would mean any time after 2020-04-01.
Note: Any relative format for min_date would always be the start of.. i.e prior-year-1 means the start of the previous year or next-year-0 would mean the start of the current year.
Any relative format for max_date would always be the end of… i.e next-year-1 would mean the end of the next year. or next-year-0 would mean the end of the current year.
Hidden Controls and the URL
Hidden controls can not be manipulated through the URL by users without Can Edit access on the workbook.
Note: If you are implementing application embedding, these values can be injected into the url during the server-side url generation process using <control_id> and <control_value>.