Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/app/elements/codelab-elements/code-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
return;
}

// Add class to pre element for styling
preElement.classList.add('has-copy-button');

// Create the copy button
const copyButton = document.createElement('button');
copyButton.className = 'copy-button';
Expand Down
8 changes: 5 additions & 3 deletions site/app/elements/codelab-elements/codelab-elements.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Let's also assume that we want to completely isolate this information from other
Log into Snowflake as `ACCOUNTADMIN`.

Copy and paste the following SQL script into a new Snowflake SQL worksheet:
```code
```copy-code
-- Use full privileges to create and configure objects
USE ROLE ACCOUNTADMIN;
USE WAREHOUSE COMPUTE_WH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ Add a new `Data` > `Table` to the page and set the source to `Sigma Sample Datab
<img src="assets/acl-1.png" width="600"/>

Add a new column, rename it to `Revenue` and set the formula to:
```code
```copy-code
[Price] * [Quantity]
```

Add another new column, rename it to `Month` and set the formula to:
```code
```copy-code
DateTrunc("month", [Date])
```

Expand Down Expand Up @@ -112,7 +112,7 @@ Rename the pivot table to `Revenue Planning`.

### Create a Key Column
In order to uniquely identify which cell a user has clicked, we will add a column renamed to `Key`, and set its formula to:
```code
```copy-code
MD5([Product Type] & [Product Line] & Text([Month]))
```

Expand Down Expand Up @@ -140,7 +140,7 @@ Add a `Input` > `Empty` input table under the `Revenue Planning` table.
Set the source connection to the `Sigma Sample Database`.

Add and name the following columns:
```code
```copy-code
Name Type
Product_Line Text
Original_Value Number
Expand All @@ -151,7 +151,7 @@ Key Text
```

Set the formula for `Delta` to:
```code
```copy-code
[Adjusted_Value] - [Original_Value]
```

Expand Down Expand Up @@ -242,7 +242,7 @@ Add a `Controls` > `Text input` control and set the `Control ID` to `a_key`.

#### Method
Add a `Controls` > `Segmented` control and set the `Control ID` to `Method`. Set the `Value source` to `Create manual list` with these values:
```code
```copy-code
Absolute
Percent
Relative
Expand All @@ -252,7 +252,7 @@ Relative

#### Calculated Adjustment
Add a `UI` > `Text` element and set its formula to:
```code
```copy-code
Coalesce(
Switch(
[Method],
Expand Down Expand Up @@ -364,7 +364,7 @@ Click as shown in the screenshot below and select `Add condition`:
<img src="assets/acl-27.png" width="500"/>

Select `Custom formula` and use this formula:
```code
```copy-code
IsNull([a_adjustment])
```

Expand All @@ -384,7 +384,7 @@ There are few things we could do here to provide feedback to the user. For examp
With that out of the way, lets setup recording the adjustment into our `Adjustment Log` input table.

`Create` (or duplicate the existing) action sequence (as shown in the screenshot below) and set its condition to execute if there is a value in
```code
```copy-code
IsNotNull([a_adjustment])
```

Expand All @@ -399,7 +399,7 @@ Add an `Insert a row` action and configure it as shown:
We need to make one change from the defaults for the `Adjusted_Value` control. For that, we need to pass the value of the final calculation but since that is not in a control for us to just "grab", we have to set a formula instead.

We can just reuse the same formula as the modal already uses to do the adjustment calculation:
```code
```copy-code
Switch([Method], "Percent", [a_current] * (1 + [a_adjustment] / 100), "Absolute", [a_adjustment], "Relative", [a_current] + [a_adjustment])
```

Expand Down Expand Up @@ -460,7 +460,7 @@ Drag `Last updated at` to the `CALCULATIONS` grouping and set its aggregation to
Rename the column to `Most Recent Adjustment`.

Add another new column and rename it to `IsLatest` and set its formula to:
```code
```copy-code
If([Last updated at] = [Most Recent Adjustment], True)
```

Expand All @@ -473,7 +473,7 @@ Lets do some test adjustments so that we have some data. Make sure to adjust the
With that configured, we now want the latest adjustment to appear in the `Revenue Planning` table, in the correct cell.

In the `Revenue Planning` table, add a new column, rename it to the `Latest Adjustment` and set the formula to:
```code
```copy-code
Coalesce(Lookup([Most Recent Adjustments/Adjusted_Value], [Key], [Most Recent Adjustments/Key]), [Sum of Revenue])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ We will configure a simple example to request weather data with the location and

**Name:** The name of the connector as it appears to users in a workbook.<br>
Use this name:
```code
```copy-code
Current Temp - Hard Coded
```

**Description:** [optional] A custom description that helps users identify the connector and verify its contents.

**Base URL:** Select an HTTP method and the URL for the request.<br>
Use this URL:
```code
```copy-code
https://api.open-meteo.com/v1/forecast?latitude=20.7702&longitude=-156.2682&timezone=auto&temperature_unit=fahrenheit
```

Expand Down Expand Up @@ -165,14 +165,14 @@ On the `Parse Temperature` page we have the same `Click Me` button and a pre-con
If we look at the KPI properties panel, we see that it is bound to the `Cities` table on the `Data` page.

Before this will work, we need to convert the raw response to JSON by adding a column to the KPI using the [Json](https://help.sigmacomputing.com/docs/json) conversion function:
```code
```copy-code
Json([Raw-Response])
```

<img src="assets/api_actions_gs_07.png" width="800"/>

Once converted, we can parse the temperature from the JSON
```code
```copy-code
Number([Raw-Response].current_weather.temperature)
```

Expand All @@ -195,7 +195,7 @@ Return to `Administration` > `API Connectors` and add a new one.

**Base URL:** Select an HTTP method and the URL for the request.<br>
Use this URL:
```code
```copy-code
https://api.open-meteo.com/v1/forecast?latitude={{latitude}}&longitude={{longitude}}&current_weather=true&temperature_unit=fahrenheit
```

Expand All @@ -204,7 +204,7 @@ https://api.open-meteo.com/v1/forecast?latitude={{latitude}}&longitude={{longitu
</aside>

**Params:** Add four query parameters:
```code
```copy-code
KEY TYPE VALUE
latitude Dynamic
longitude Dynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Add a new `Data` > `Table` to the page and set the source to `Sigma Sample Datab
<img src="assets/acl-1.png" width="600"/>

Add a new column, rename it to `Revenue` and set the formula to:
```code
```copy-code
[Price] * [Quantity]
```
Let's cull the data down for this demonstration. We don't need 4.5 million rows to build our AI App, although Sigma handles it fine anyway. There is no reason to use more data than is required and efficiency matters.
Expand All @@ -82,7 +82,7 @@ Let's just assume these are the orders in the cloud data warehouse ("warehouse")
Since it is possible that each order can have multiple items (`SKUs`), we need to add a column to ensure that we can easily identify any row uniquely.

Add a new column, rename it to `Key` and set the formula to:
```code
```copy-code
MD5(Text([Order Number]) & [Sku Number] & Text([Cust Key]))
```

Expand Down Expand Up @@ -151,7 +151,7 @@ Duration: 5
We want the AI App to open a modal window when the user clicks on a single cell in a specific row.

Let's make it really obvious for the user and add a new `Calculation` column to `Orders to Approve` and rename it to `Edit`. Set the formula to:
```code
```copy-code
"EDIT"
```

Expand Down Expand Up @@ -307,7 +307,7 @@ Repeat to create a second container for the `Order Details` controls:
<img src="assets/af-20a.png" width="600"/>

Here is the text for `Instructions`:
```code
```copy-code
An adjustment is requested on this order and line item.

Make sure to include some information with your update.
Expand All @@ -334,7 +334,7 @@ Set the connection to the `Sigma sample database`.
We will need to add and configure a few columns. These columns will be populated by data sent by the `Approvals Modal` when the user saves an override.

Add and configure the following columns:
```code
```copy-code
Column Name: Type:
Order Number Number
Previous Revenue Number
Expand Down Expand Up @@ -378,7 +378,7 @@ Group the table on `Key` and drag `Last Updated at` to `CALCULATIONS`, changing
<img src="assets/af-36.png" width="500"/>

Add an new column and rename it to `IsLatest`. Set the formula to:
```code
```copy-code
If([Last updated at] = [Max of Last updated at], True)
```

Expand Down Expand Up @@ -543,7 +543,7 @@ Rename the copy to `Approver Modal` and change its title to match.
<img src="assets/af-45.png" width="500"/>

Next we will update the `Instructions` to:
```code
```copy-code
An adjustment is requested on this order and line item.

Rm Override shows the latest requested adjustment.
Expand Down Expand Up @@ -644,14 +644,14 @@ Now when the adjusted clicks on a `Rejected` row, they use the same `Adjuster Mo
Duration: 5

On the `Orders to Approve` table, add a new `Calculation` column to the `Orders to Approve` table, setting the formula to:
```code
```copy-code
Switch([a_persona], "Adjuster", [Latest Status (Most Recent Adjustments)] = "Rejected" or IsNull([Latest Status (Most Recent Adjustments)]), "Approver", [Latest Status (Most Recent Adjustments)] = "Adjusted" or [Latest Status (Most Recent Adjustments)] = "Approved", False)
```

Rename it to `Persona Access`.

Create another `Calculation` column, renamed to `Persona` with this formula:
```code
```copy-code
If(Lookup([Latest Status (Most Recent Adjustments)], [Key], [Latest Status (Most Recent Adjustments)]) = "Adjusted", "Adjuster", "Approver")
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ For that level of detail, please see [External Functions.](https://docs.snowflak
Log into your Snowflake instance as `ACCOUNTADMIN` and create a new SQL worksheet.

### Load the "Dirty" Dataset in Snowflake, by running this script:
```code
```copy-code
-- Step 1: Create a database and schema for logging requests and responses
CREATE DATABASE IF NOT EXISTS SIGMA_QUICKSTARTS;
USE DATABASE SIGMA_QUICKSTARTS;
Expand Down Expand Up @@ -131,7 +131,7 @@ This is a simple process that takes only a few minutes.
Once you have the API key, replace the text on line 42 (search for **"YOUR_API_KEY_HERE"**) of the script with your key.

Run the following script in a Snowflake SQL worksheet:
```code
```copy-code
-- Step 1: Set correct database
USE DATABASE SIGMA_QUICKSTARTS;
USE SCHEMA GEOCODIO_API;
Expand Down Expand Up @@ -204,7 +204,7 @@ Before moving off this script, comment out the last line that tests the UDF. We
`Run All` again to update the UDF.

### Create a PROCEDURE, by running this script:
```code
```copy-code
-- Step 1: Set correct database
USE DATABASE SIGMA_QUICKSTARTS;
USE SCHEMA GEOCODIO_API;
Expand Down Expand Up @@ -347,7 +347,7 @@ Add another table to the page, this time selecting `REQUEST_RESPONSE_LOG` from t
Rename the second table to `Clean Addresses`.

Add a new column to the `Dirty Data` table, rename it to `Cleaned ?` and set the formula to:
```code
```copy-code
If(IsNotNull(Lookup([Clean Addresses/Business Id], [Business Id], [Clean Addresses/Business Id])), "YES", "NO")
```

Expand All @@ -365,7 +365,7 @@ The Geocodio API endpoint we are using is expecting a single comma-separated str
The `Dirty Data` that was provided to us has each part of the address in individual columns, so we need to combine them, before sending the API request. This is simple to do.

Add a new column to the `Dirty Data` table, rename it to `Request_Address` and set the formula to:
```code
```copy-code
Text([Business Id]) & " || " & [Address] & ", " & [City] & ", " & [State] & ", " & [Dirty Zip]
```

Expand Down Expand Up @@ -446,22 +446,22 @@ The `Response Data` column in the `Clean Addresses` table is storing the address
Add columns for `Street`, `City`, `State` and `Zip`. Here are the formulas for each, using the [SplitPart function.](https://help.sigmacomputing.com/docs/splitpart)

**Street:**
```code
```copy-code
SplitPart([Response Data], ",", 1)
```

**City:**
```code
```copy-code
SplitPart([Response Data], ",", 2)
```

**State:**
```code
```copy-code
SplitPart(Trim(SplitPart([Response Data], ",", 3)), " ", 1)
```

**Zip:**
```code
```copy-code
SplitPart(Trim(SplitPart([Response Data], ",", 3)), " ", 2)
```

Expand Down
Loading