### Product List Loop Example Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/syntax-reference.md An example demonstrating how to loop through rows and display product names and their corresponding revenue. ```html {% map(rows) %} {{ `Product Name` }} - {{ values.`Revenue` }} {% end %} ``` -------------------------------- ### Render Multiple Metric Nodes Example Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/gallery/metrics-tree.md HTML examples showcasing the rendering of multiple metric nodes, including those with positive and negative indicators. These examples illustrate how different metrics are structured within the tree. ```html
Buyers {{ col_totals.`Buyers` }} People who purchased
AOV {{ col_totals.`Aov` }} Avg order value
COGS {{ col_totals.`Cogs` }} Cost to make
Shipping {{ col_totals.`Shipping` }} Cost to deliver
``` ```html
Sessions {{ col_totals.`Sessions` }} Traffic
Conversion Rate {{ col_totals.`Conversion Rate` }} Sessions → buyers
``` -------------------------------- ### Render Metric Node Example Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/gallery/metrics-tree.md An HTML example demonstrating how to render a single metric node within the metrics tree. It includes placeholders for dynamic data and descriptive text. ```html
North Star {{ col_totals.`North Star`.formatted }} Primary outcome
``` -------------------------------- ### Install Holistics CLI on macOS and Linux Source: https://docs.holistics.io/docs/cli.md Run this command to install the Holistics CLI. The installation script supports bash, zsh, and fish shells. ```bash curl -fsSL https://raw.githubusercontent.com/holistics/holistics-cli/refs/heads/master/install.sh | bash ``` -------------------------------- ### Example: Using Imported Models in a Dataset View Source: https://docs.holistics.io/docs/datasets/custom-views.md A practical example demonstrating how to import models from different modules ('sales', 'customers') and use them within a dataset view, including defining relationships and selecting specific fields. ```aml use sales { orders, products } use customers { users } Dataset ecommerce { label: 'Ecommerce Dataset' data_source_name: 'demodb' models: [orders, products, users] relationships: [ relationship(orders.user_id > users.id, true), relationship(orders.product_id > products.id, true) ] view { model products { } // Display all fields from Products model users { // Display selected fields from Users field id field email field full_name } // Group models together group order_details { model orders { field id field order_value field order_status } } } } ``` -------------------------------- ### Set up dbt with BigQuery Adapter Source: https://docs.holistics.io/docs/continuous-integration/automatic-dbt-integration.md Installs the dbt BigQuery adapter using pip and runs `dbt deps` to install any necessary packages defined in the dbt project. ```yaml - name: Set up dbt run: | pip3 install dbt-bigquery; dbt deps; ``` -------------------------------- ### Example Dataset View for Ecommerce Data Source: https://docs.holistics.io/docs/datasets/custom-views.md This example demonstrates a custom view for an ecommerce dataset, including all fields from 'products', selected fields and a grouped field for 'users', and grouped models for 'orders' and 'dim_dates'. ```aml Dataset ecommerce { ... models: [users, products, orders, dim_dates] relationships: [ relationship(orders.user_id > users.id, true), relationship(orders.product_id > products.id, true), relationship(orders.order_date > dim_dates.id, true) ] view { model products { } // Display all fields from Products model users { // Display selected fields from Users field id field email field age // Create group "Customer Name" containing fields within model Users group customer_name { field first_name field last_name field full _name } } // Create group "Order Master" containing two models Orders and Dates group order_master { model orders { field order_value field id field order_status field order_discount } model dim_dates { field year field month name field day field week_number field quarter } } } } ``` -------------------------------- ### Project Structure Example Source: https://docs.holistics.io/docs/development/aml-studio.md Illustrates a recommended folder layout for organizing AML files, separating models and datasets by region. ```tree data_warehouse ├── region_asia │ ├── orders.model.aml // contains model orders_asia │ ├── products.model.aml // contains model products_asia │ └── business_metrics.dataset.aml // contains dataset business_metrics_asia | └── region_europe ├── orders.model.aml // contains model orders_europe ├── products.model.aml // contains model products_europe └── business_metrics.dataset.aml // contains dataset business_metrics_europe ``` -------------------------------- ### Install Holistics CLI Source: https://docs.holistics.io/docs/continuous-integration/automatic-dbt-integration.md Downloads and installs the Holistics CLI using a curl command and adds its binary directory to the GitHub Actions PATH for subsequent use. ```yaml - name: Install Holistics CLI run: | curl -fsSL https://raw.githubusercontent.com/holistics/holistics-cli/refs/heads/master/install.sh | bash echo "$HOME/.holistics/bin" >> $GITHUB_PATH ``` -------------------------------- ### Complete Pivot Table Example (Retention Heatmap) Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/syntax-reference.md A comprehensive example demonstrating how to structure a retention heatmap using nested loops for rows, columns, and cell values. It includes headers and data cells. ```html {% map(rows) %} {{ `Cohort Month` }} {% map(values) %} {{ value.`Total Users` }} {% end %} {% end %} ``` -------------------------------- ### Looker Filter Configuration Example Source: https://docs.holistics.io/docs/from-others/looker/dashboard-migration.md Demonstrates a Looker filter configuration with field, model, explore, and UI settings. ```yml - dashboard: sales_overview crossfilter_enabled: true filters: - name: order_status title: "Order Status" type: field_filter model: sales explore: orders field: orders.status default_value: "completed" allow_multiple_values: true ui_config: type: dropdown_menu display: popover ``` -------------------------------- ### Install VS Code Extension Source: https://docs.holistics.io/docs/development/local-development-workflow.md Install the Holistics VS Code extension to enable syntax highlighting, autocomplete, hover information, and go-to-definition for AML files. ```bash code --install-extension holistics.holistics-aml-vscode-ext ``` -------------------------------- ### Example autossh command for reverse tunnel Source: https://docs.holistics.io/docs/connect/connect-tunnel.md An example of the `autossh` command with specific values for connecting to a PostgreSQL database. This demonstrates how to map a local database port to a remote tunnel port. ```bash autossh -M 0 -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" \ -R *:20032:db.somehost.com:5432 \ autossh@tunnel.holistics.io -p 50022 \ -i ~/.ssh/id_rsa ``` -------------------------------- ### Examples of Relative Date Expressions Source: https://docs.holistics.io/docs/datetimes/relative-dates.md Illustrates various combinations of start and end points, including same and different time units, and simple relative spans. ```text April 15 2024 to may 15 2024 ``` ```text 2024-04-15 to 2024-05-15 ``` ```text April 15 2024 until may 16 2024 ``` ```text 2024-04-15 till 2024-05-16 ``` ```text 30 april 2024 12:00 till 30 april 2024 14:00 ``` ```text last 3 days ``` ```text next 3 weeks ``` ```text last 10 hours ``` ```text next 30 minutes ``` ```text 2023 to september 2024 ``` ```text 2 months ago to monday last week ``` ```text this year begin to this week end ``` ```text yesterday to now ``` ```text this weekend to next 2 months ``` -------------------------------- ### Microsoft Forms Integration Source: https://docs.holistics.io/docs/access-control/custom-access-request-page.md An HTML example for integrating with Microsoft Forms, suitable for Office 365 users. This setup allows for creating access request forms. ```html Request via Microsoft Forms ``` -------------------------------- ### Create a Top Product Card Template Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/getting-started.md Build a styled card to display the top product and its revenue. This example uses HTML for structure and styling, with template syntax to inject dynamic data. ```html Top Product {{ rows[0].`Product Name` }} {{ rows[0].values.`Revenue` }} ``` -------------------------------- ### Syntax Error Example Source: https://docs.holistics.io/docs/continuous-integration/auto-publish.md This JSON response indicates a syntax error in the project. The 'error_details' field specifies the file path, start and end offsets, and the error message. ```json { "status": "success", // job status "error": null, "result": { // result of the publishing process "type": "Publish", "data": { "status": "error", // publish status "error_type": "syntax_error", "error_details": { "diagnostics": [ { "category": "Error", "code": 1000, "message": "Unexpected ';'", "filePath": "/ecommerce_dashboard.page.aml", // file path contain the error "start": 1469, // offset of the error in the code "end": 1470 // offset of the error in the code } ] }, "target_commit": "0bf1e7421b78eea7d9ce4ac9d07db9584e5c5d76" } } } ``` -------------------------------- ### Create and Configure SFTP Directories Source: https://docs.holistics.io/docs/delivery/sftp-schedules.md Sets up the necessary directories for SFTP access. The parent directory `/holistics` is owned by root for Chroot configuration, while the inner `exported` directory is owned by the SFTP user for file storage. ```bash mkdir -p /holistics chown root: /holistics ``` ```bash mkdir -p /holistics/exported chown holistics_sftp: /holistics/exported chmod 0755 /holistics/exported ``` -------------------------------- ### Example: One-Way Relationships in a Galaxy Schema Source: https://docs.holistics.io/docs/joins/filter-direction.md In multi-fact setups like galaxy schemas, use `one_way` relationships to prevent unintended join paths and misleading results. This example shows how to set up one-way relationships for orders and inventory facts connected to products, ensuring metrics are grouped only by relevant dimensions. ```aml Dataset ecommerce { ... models: [ dim_users, dim_products, dim_cities, dim_merchants, dim_categories, fact_orders, fact_inventory ] relationships: [ //highlight-start relationship(fact_orders.user_id > dim_users.id, true, 'one_way'), relationship(fact_orders.product_id > dim_products.id, true, 'one_way'), relationship(fact_inventory.product_id > dim_products.id, true, 'one_way'), relationship(dim_users.city_id > dim_cities.id, true, 'one_way'), relationship(dim_products.merchant_id > dim_merchants.id, true, 'one_way'), relationship(dim_products.category_id > dim_categories.id, true, 'one_way') //highlight-end ] } ``` -------------------------------- ### Valid Object Names Source: https://docs.holistics.io/docs/development/aml-studio.md Examples of valid object names for models, datasets, etc. Must not start with a number or special character (except '_') and must not contain spaces or special characters. Snake_case is recommended. ```text order_master OrderMaster _order_master business_metrics ``` -------------------------------- ### Run EXPLAIN ANALYZE on Slow Queries Source: https://docs.holistics.io/docs/performance/troubleshooting.md Append EXPLAIN ANALYZE to your generated SQL and run it against your data warehouse to reveal the query plan and identify performance bottlenecks. Paste the output into tools like explain.depesz.com for visualization. ```sql EXPLAIN ANALYZE /* - Job ID: xxxxxxxxxx* */ SELECT * FROM your_table WHERE condition; ``` -------------------------------- ### Check autossh Installation Path Source: https://docs.holistics.io/docs/connect/connect-tunnel.md Determine the installation path of the autossh command. This is useful for identifying if autossh was installed via snap, which may cause issues. ```bash which autossh ``` ```bash command -v autossh ``` -------------------------------- ### Check Database Connectivity (MySQL CLI) Source: https://docs.holistics.io/docs/connect/connect-tunnel.md Connect to your database using its command-line interface (CLI) to verify connectivity and credentials. This example uses the MySQL client. ```bash mysql -h -P -u -p ``` -------------------------------- ### Install autossh on Debian/Ubuntu Source: https://docs.holistics.io/docs/connect/connect-tunnel.md Install the `autossh` package on Debian-based systems. This tool is used to maintain SSH tunnels. ```bash sudo apt-get update sudo apt-get install autossh ``` -------------------------------- ### Start a screen session for autossh Source: https://docs.holistics.io/docs/connect/connect-tunnel.md Start a named screen session to run `autossh` in the background. This allows the tunnel to persist even if you disconnect from your terminal. ```bash sudo apt-get install screen screen -S holistics ``` -------------------------------- ### Set up Python Environment Source: https://docs.holistics.io/docs/continuous-integration/automatic-dbt-integration.md Configures the GitHub Actions runner to use a specific Python version (3.7 in this case) using the actions/setup-python@v4 action. ```yaml - name: Set up Python uses: actions/setup-python@v4 with: python-version: 3.7 ``` -------------------------------- ### AQL Query: Total Revenue by Product Category Source: https://docs.holistics.io/docs/modeling/modeling-patterns/star-schema.md An example AQL query to calculate the total revenue for each product category, leveraging the star schema structure. ```aql explore { dimensions { dim_products.category } measures { fct_orders.total_revenue } } ``` -------------------------------- ### Example of Filter Order: Date and Top N Source: https://docs.holistics.io/docs/top-bottom-n-filter.md Demonstrates how a date filter is applied before a Top N filter, resulting in a different set of top products. ```text Sony Smart TV, Body Cleanser and Sofa 1 ``` -------------------------------- ### Explore Data Using Defined Metrics and Dimensions Source: https://docs.holistics.io/docs/modeling/modeling-patterns/galaxy-schema.md Use the explore function to query the dataset, selecting dimensions, measures, and applying filters. This example filters data for the last 6 months. ```aql explore { dimensions { dim_products.name } measures { total_available_products, total_gmv } filters { dim_dates.date matches @(last 6 months) } } ``` -------------------------------- ### Jotform Integration Source: https://docs.holistics.io/docs/access-control/custom-access-request-page.md This HTML snippet demonstrates how to set up a Jotform for access requests. Jotform supports URL parameters for pre-filling form fields. ```html Request via Jotform ``` -------------------------------- ### String Interpolation Syntax Example Source: https://docs.holistics.io/docs/charts/understand-custom-chart Demonstrates the syntax for referencing properties of declared objects and interpolating their values into a template. Use dot notation with '@{' and '}' for interpolation. ```text @{object.object_name.object_property} ``` -------------------------------- ### Render Positive/Negative Metric Node Example Source: https://docs.holistics.io/docs/charts/dynamic-content-blocks/gallery/metrics-tree.md HTML examples for rendering metric nodes with positive or negative indicators. The 'pos' and 'neg' classes apply distinct border colors to visually represent the metric's status. ```html
Revenue {{ col_totals.`Revenue` }} Money from customers
Cost {{ col_totals.`Cost` }} Money paid out
``` -------------------------------- ### Runtime Data Example Source: https://docs.holistics.io/docs/charts/custom-chart-properties Shows the structure of runtime data returned during chart execution, including data values, field properties, and option values. ```json { data: { values: [ {a: "01/01/2022", b: 28}, {a: "01/02/2022", b: 55}, {a: "01/03/2022", b: 43}, ] }, fields: { a: { name: "Created_at" type: "date" format: "mm/dd/yyyy" } b: { name: "Sum of Revenue" type: "number" format: "Number (rounded)" } }, options: { tooltip: { value: true }, } } ``` -------------------------------- ### Select Time Span Between Two Points Source: https://docs.holistics.io/docs/datetimes/relative-dates.md Use expressions like '[start] -/to [end]' to select all dates between two points, including the end point. '[start]' and '[end]' can be any exact-unit expression with potentially different time granularities. ```text 2024-04-15 - this month end ``` ```text today to this month end ``` ```text last 3 hours to this minute ``` -------------------------------- ### Generate SEO Descriptions with AI Source: https://docs.holistics.io/docs/ai/run-ai-functions.md Employ `ai_complete` to generate SEO-optimized descriptions for products. This function requires specifying an AI model and a prompt that includes product details. ```aml dimension seo_description { type: 'text' definition: @aql // highlight-start ai_complete( 'gpt-4', concat('Write a 50-word SEO-optimized description for: ', name, '. ', description) ) // highlight-end ;; } ``` -------------------------------- ### Enable Cross Filter with `crossFilterSignals` Source: https://docs.holistics.io/docs/charts/custom-chart-properties Combine Vega-lite's `params` with `holisticsConfig` to enable Cross Filter. This example declares a point selection and maps it to `crossFilterSignals`. ```json template: @vgl { ... "params": [ // 1. Point selection is declared here {"name": "myPointSelection", "select": "point"} ], ... "holisticsConfig": { // 2. Point selection now triggers cross filter on your chart "crossFilterSignals": ["myPointSelection"], } } ``` -------------------------------- ### Select Time Span Excluding End Point Source: https://docs.holistics.io/docs/datetimes/relative-dates.md Use expressions like '[start] till/until [end]' to select all dates between two points, excluding the end point. '[start]' and '[end]' can be any exact-unit expression with potentially different time granularities. ```text today till this month end ``` ```text last 3 hours to this minute ``` -------------------------------- ### Get Current Time with now() Source: https://docs.holistics.io/docs/expression.md The now() function returns the current date and time. ```expression now() ``` -------------------------------- ### Run Slack Bot Source: https://docs.holistics.io/docs/ai/guides/running-a-self-hosted-slack-bot.md Execute the slack-mcp-client command within the slack-bot directory to start the bot. Ensure you are in the correct folder where config.json and .env are located. ```bash # within slack-bot folder (created in step D.2) slack-mcp-client ``` -------------------------------- ### Create Oracle User and Grant CONNECT Source: https://docs.holistics.io/docs/connect/create-db-user.md Create an Oracle user 'holistics' with a password and grant it the CONNECT role. Oracle schemas are equivalent to user accounts. ```sql -- create user CREATE USER holistics IDENTIFIED BY 'USE_A_NICE_STRONG_PASSWORD_PLEASE'; -- grant select for this user GRANT CONNECT TO holistics; ``` -------------------------------- ### Date-drill Filter Examples Source: https://docs.holistics.io/docs/url-parameters.md Use the '=' operator for date-drill filters. The parameter is case-insensitive. ```url url?date_drill=Month ``` ```url url?date_drill=year ``` -------------------------------- ### Holistics Dataset Structure Source: https://docs.holistics.io/docs/from-others/looker/model-migration.md Example of Holistics dataset files corresponding to Looker explores. ```aml // in datasets/orders.dataset.aml Dataset orders { data_source_name: 'warehouse' // ... dataset configuration } // in datasets/products.dataset.aml Dataset products { data_source_name: 'warehouse' // ... dataset configuration } ``` -------------------------------- ### Number Filter Example Source: https://docs.holistics.io/docs/url-parameters.md Use the '=' operator for number filters. Both integer and float values are supported. ```url url?score=8 ``` ```url url?score=8.0 ``` -------------------------------- ### Project structure for library blocks Source: https://docs.holistics.io/docs/canvas-dashboard/guides/build-library-blocks.md Illustrates the file structure created when a block is added to the library, highlighting the location of the reusable block file. ```tree ├── library │ └── blocks │ └── mrr_pop_growth.block.aml <-- Your reusable block is created here //highlight-end ├── settings ├── models │ └── model_1.model.aml ├── datasets │ └── dataset_1.dataset.aml └── dashboards └── saas.page.aml ``` -------------------------------- ### String/Boolean Filter Example Source: https://docs.holistics.io/docs/url-parameters.md Use the '=' operator for string and boolean filters. Query values are case-sensitive. ```url url?country=Vietnam ``` ```url url?is_male=false ``` -------------------------------- ### Create Holistics User and Assign Role Source: https://docs.holistics.io/docs/connect/databases/snowflake.md Create a dedicated user for Holistics, set their default warehouse and role, and assign the HOLISTICS_ROLE to them. Replace MY_PASSWORD with a strong password. ```sql CREATE USER "HOLISTICS_USER" MUST_CHANGE_PASSWORD = FALSE DEFAULT_WAREHOUSE ="DEMO_WH" DEFAULT_ROLE = "HOLISTICS_ROLE" PASSWORD = "MY_PASSWORD"; GRANT ROLE "HOLISTICS_ROLE" TO USER "HOLISTICS_USER"; ``` -------------------------------- ### Holistics Basic Dashboard Structure Source: https://docs.holistics.io/docs/from-others/looker/dashboard-migration.md Example of a Holistics dashboard configuration, including title, description, and settings. ```tsx Dashboard sales_overview { title: "Sales Overview" description: "Sales performance metrics and trends" settings { autorun: true } view: CanvasLayout { width: 1560 // Dashboard width in pixels height: 1080 // Dashboard height in pixels } } ```