Skip to content

Commit f8346b4

Browse files
authored
Merge pull request #551 from sigmacomputing/copy-code-rollout
more changes and final markdown revisions
2 parents 2e5f4a0 + 3181959 commit f8346b4

64 files changed

Lines changed: 510 additions & 505 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

site/app/elements/codelab-elements/code-copy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
return;
2222
}
2323

24+
// Add class to pre element for styling
25+
preElement.classList.add('has-copy-button');
26+
2427
// Create the copy button
2528
const copyButton = document.createElement('button');
2629
copyButton.className = 'copy-button';

site/app/elements/codelab-elements/codelab-elements.css

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/sigmaguides/src/administration_ask_sigma_usage_dashboard/administration_ask_sigma_usage_dashboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Let's also assume that we want to completely isolate this information from other
100100
Log into Snowflake as `ACCOUNTADMIN`.
101101

102102
Copy and paste the following SQL script into a new Snowflake SQL worksheet:
103-
```code
103+
```copy-code
104104
-- Use full privileges to create and configure objects
105105
USE ROLE ACCOUNTADMIN;
106106
USE WAREHOUSE COMPUTE_WH;

site/sigmaguides/src/aiapps_adjustments_change_log/aiapps_adjustments_change_log.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ Add a new `Data` > `Table` to the page and set the source to `Sigma Sample Datab
7373
<img src="assets/acl-1.png" width="600"/>
7474

7575
Add a new column, rename it to `Revenue` and set the formula to:
76-
```code
76+
```copy-code
7777
[Price] * [Quantity]
7878
```
7979

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

@@ -112,7 +112,7 @@ Rename the pivot table to `Revenue Planning`.
112112

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

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

142142
Add and name the following columns:
143-
```code
143+
```copy-code
144144
Name Type
145145
Product_Line Text
146146
Original_Value Number
@@ -151,7 +151,7 @@ Key Text
151151
```
152152

153153
Set the formula for `Delta` to:
154-
```code
154+
```copy-code
155155
[Adjusted_Value] - [Original_Value]
156156
```
157157

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

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

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

366366
Select `Custom formula` and use this formula:
367-
```code
367+
```copy-code
368368
IsNull([a_adjustment])
369369
```
370370

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

386386
`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
387-
```code
387+
```copy-code
388388
IsNotNull([a_adjustment])
389389
```
390390

@@ -399,7 +399,7 @@ Add an `Insert a row` action and configure it as shown:
399399
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.
400400

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

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

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

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

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

site/sigmaguides/src/aiapps_api_actions_getting_started/aiapps_api_actions_getting_started.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ We will configure a simple example to request weather data with the location and
8282

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

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

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

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

167167
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:
168-
```code
168+
```copy-code
169169
Json([Raw-Response])
170170
```
171171

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

174174
Once converted, we can parse the temperature from the JSON
175-
```code
175+
```copy-code
176176
Number([Raw-Response].current_weather.temperature)
177177
```
178178

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

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

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

206206
**Params:** Add four query parameters:
207-
```code
207+
```copy-code
208208
KEY TYPE VALUE
209209
latitude Dynamic
210210
longitude Dynamic

site/sigmaguides/src/aiapps_approvals_flow/aiapps_approvals_flow.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Add a new `Data` > `Table` to the page and set the source to `Sigma Sample Datab
6262
<img src="assets/acl-1.png" width="600"/>
6363

6464
Add a new column, rename it to `Revenue` and set the formula to:
65-
```code
65+
```copy-code
6666
[Price] * [Quantity]
6767
```
6868
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.
@@ -82,7 +82,7 @@ Let's just assume these are the orders in the cloud data warehouse ("warehouse")
8282
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.
8383

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

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

153153
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:
154-
```code
154+
```copy-code
155155
"EDIT"
156156
```
157157

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

309309
Here is the text for `Instructions`:
310-
```code
310+
```copy-code
311311
An adjustment is requested on this order and line item.
312312
313313
Make sure to include some information with your update.
@@ -334,7 +334,7 @@ Set the connection to the `Sigma sample database`.
334334
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.
335335

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

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

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

545545
Next we will update the `Instructions` to:
546-
```code
546+
```copy-code
547547
An adjustment is requested on this order and line item.
548548
549549
Rm Override shows the latest requested adjustment.
@@ -644,14 +644,14 @@ Now when the adjusted clicks on a `Rejected` row, they use the same `Adjuster Mo
644644
Duration: 5
645645

646646
On the `Orders to Approve` table, add a new `Calculation` column to the `Orders to Approve` table, setting the formula to:
647-
```code
647+
```copy-code
648648
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)
649649
```
650650

651651
Rename it to `Persona Access`.
652652

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

site/sigmaguides/src/aiapps_calling_external_api_procedure/aiapps_calling_external_api_procedure.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ For that level of detail, please see [External Functions.](https://docs.snowflak
7979
Log into your Snowflake instance as `ACCOUNTADMIN` and create a new SQL worksheet.
8080

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

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

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

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

@@ -365,7 +365,7 @@ The Geocodio API endpoint we are using is expecting a single comma-separated str
365365
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.
366366

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

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

448448
**Street:**
449-
```code
449+
```copy-code
450450
SplitPart([Response Data], ",", 1)
451451
```
452452

453453
**City:**
454-
```code
454+
```copy-code
455455
SplitPart([Response Data], ",", 2)
456456
```
457457

458458
**State:**
459-
```code
459+
```copy-code
460460
SplitPart(Trim(SplitPart([Response Data], ",", 3)), " ", 1)
461461
```
462462

463463
**Zip:**
464-
```code
464+
```copy-code
465465
SplitPart(Trim(SplitPart([Response Data], ",", 3)), " ", 2)
466466
```
467467

0 commit comments

Comments
 (0)