From a7ebea75b01ffd61677cecfaab2d9cc3858b7ff2 Mon Sep 17 00:00:00 2001 From: Chinh Date: Mon, 3 Nov 2025 14:02:08 +0000 Subject: [PATCH 1/8] Modify: team-folders/Chinh/dashboards/chinh_sandbox.page.aml, team-folders/Chinh/datasets/ticket_23584.dataset.aml --- .../Chinh/dashboards/chinh_sandbox.page.aml | 5 +++-- .../Chinh/datasets/ticket_23584.dataset.aml | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/team-folders/Chinh/dashboards/chinh_sandbox.page.aml b/team-folders/Chinh/dashboards/chinh_sandbox.page.aml index 44140c0..5555a13 100644 --- a/team-folders/Chinh/dashboards/chinh_sandbox.page.aml +++ b/team-folders/Chinh/dashboards/chinh_sandbox.page.aml @@ -5,7 +5,7 @@ Dashboard chinh_sandbox { view: CanvasLayout { label: 'View 1' width: 1300 - height: 900 + height: 800 grid_size: 20 auto_expand_vertically: true mobile { @@ -51,6 +51,7 @@ Dashboard chinh_sandbox { type: 'number' pattern: 'inherited' } + hidden: true }, VizFieldFull { ref: r(ticket_23584.total_amount) @@ -95,7 +96,7 @@ Dashboard chinh_sandbox { } } block f_nfvl: FilterBlock { - label: 'Category' + label: 'All Category' type: 'field' source: FieldFilterSource { dataset: ticket_23584 diff --git a/team-folders/Chinh/datasets/ticket_23584.dataset.aml b/team-folders/Chinh/datasets/ticket_23584.dataset.aml index 970bb66..f7e9d7e 100644 --- a/team-folders/Chinh/datasets/ticket_23584.dataset.aml +++ b/team-folders/Chinh/datasets/ticket_23584.dataset.aml @@ -22,16 +22,15 @@ Dataset ticket_23584 { definition: @aql sum(chinh_fact_sales.sales_amount) ;; } - dimension products_ordered_within_2_years { + dimension amount_per_product_ordered_within_2_years { model: chinh_dim_category - label: 'Products (ordered within 2 years)' + label: 'Amount per Products (ordered within 2 years)' type: 'number' definition: @aql dimensionalize( - chinh_fact_sales - | filter(chinh_fact_sales.created_at > @(last 2 years)) - | count(chinh_dim_product.product_id) - , chinh_dim_category.category_id + total_amount + | where(chinh_fact_sales.created_at > @(last 2 years)), + chinh_dim_category.category_id ) ;; } @@ -42,7 +41,9 @@ Dataset ticket_23584 { type: 'text' definition: @aql case( - when: chinh_dim_category.products_ordered_within_2_years > 0, then: chinh_dim_category.category, + when: chinh_dim_category.amount_per_product_ordered_within_2_years > 0, + then: chinh_dim_category.category, + else: null ) ;; From 3248656be73a9f28df68d8baf2991fb42bc34e67 Mon Sep 17 00:00:00 2001 From: Chinh Date: Fri, 28 Nov 2025 07:46:45 +0000 Subject: [PATCH 2/8] Add 'chinh_test_table' block, 'chinh_template' and update 'chinh_sandbox' dashboard with tabs and dataset filter logic --- library/blocks/chinh_test_table.block.tpl.aml | 82 ++++++++++++++ .../Chinh/dashboards/chinh_sandbox.page.aml | 104 +++++++++++++++--- .../Chinh/dashboards/chinh_template.page.aml | 53 +++++++++ .../Chinh/datasets/ticket_23584.dataset.aml | 20 +++- 4 files changed, 236 insertions(+), 23 deletions(-) create mode 100644 library/blocks/chinh_test_table.block.tpl.aml create mode 100644 team-folders/Chinh/dashboards/chinh_template.page.aml diff --git a/library/blocks/chinh_test_table.block.tpl.aml b/library/blocks/chinh_test_table.block.tpl.aml new file mode 100644 index 0000000..8bdd7fa --- /dev/null +++ b/library/blocks/chinh_test_table.block.tpl.aml @@ -0,0 +1,82 @@ +// This is a library dashboard block. For more details, visit https://docs.holistics.io/docs/canvas-dashboard/guides/build-library-blocks +@template( + title='Chinh Test Table', + description='', + thumbnail='', + metadata={ + group: '' + block_width: 1260 + block_height: 680 + } +) +Func block_chinh_test_table() { + VizBlock { + label: 'Table' + viz: DataTable { + dataset: ticket_23584 + fields: [ + VizFieldFull { + ref: r(chinh_dim_date.date) + format { + type: 'date' + } + uname: 'chinh_dim_date_date' + }, + VizFieldFull { + ref: r(chinh_dim_category.category) + format { + type: 'text' + } + uname: 'chinh_dim_category_category_1' + }, + VizFieldFull { + ref: r(ticket_23584, chinh_dim_category.active_category) + format { + type: 'number' + pattern: 'inherited' + } + hidden: true + }, + VizFieldFull { + ref: r(ticket_23584.total_amount) + format { + type: 'number' + pattern: 'inherited' + } + } + ] + settings { + show_row_number: true + sorts: [ + SortSetting { + key: 'chinh_dim_date_date' + direction: 'desc' + }, + SortSetting { + key: 'chinh_dim_category_category_1' + direction: 'asc' + } + ] + conditional_formats: [ + ConditionalFormat { + key: 'chinh_dim_date_date' + format: SingleFormat { + condition { + operator: 'before' + value: '2023-12-31' + } + text_color: '#BF0E08' + background_color: '#FAD2D1' + apply_to_row: true + } + } + ] + row_limit: 5000 + aggregate_awareness { + enabled: true + debug_comments: true + } + } + } + } +} \ No newline at end of file diff --git a/team-folders/Chinh/dashboards/chinh_sandbox.page.aml b/team-folders/Chinh/dashboards/chinh_sandbox.page.aml index 5555a13..f2f8c8c 100644 --- a/team-folders/Chinh/dashboards/chinh_sandbox.page.aml +++ b/team-folders/Chinh/dashboards/chinh_sandbox.page.aml @@ -1,27 +1,94 @@ +@template( + title='View Template', + description='', + thumbnail='', + metadata={ + } +) +Func view_template() { + TabLayout { + label: 'View 1' + tab tab1: CanvasLayout { + label: 'Tab 1' + width: 1300 + height: 1500 + grid_size: 20 + auto_expand_vertically: true + block v_0m6g { + position: pos(20, 100, 1260, 680) + layer: 1 + } + block f_nfvl { + position: pos(20, 20, 300, 80) + layer: 2 + } + block f_dtbw { + position: pos(340, 20, 300, 80) + layer: 3 + } + block v_sfkb { + position: pos(20, 800, 1260, 2000) + layer: 4 + } + mobile { + mode: 'auto' + } + } + tab tab2: CanvasLayout { + label: 'Tab 2' + width: 2000 + height: 800 + grid_size: 20 + auto_expand_vertically: true + mobile { + mode: 'auto' + } + } + } +} + Dashboard chinh_sandbox { title: 'Chinh Sandbox' description: '' - view: CanvasLayout { + // view: view_template() + view: TabLayout { label: 'View 1' - width: 1300 - height: 800 - grid_size: 20 - auto_expand_vertically: true - mobile { - mode: 'auto' - } - block v_0m6g { - position: pos(20, 100, 1260, 680) - layer: 1 - } - block f_nfvl { - position: pos(20, 20, 300, 80) - layer: 2 + tab tab1: CanvasLayout { + label: 'Tab 1' + width: 1300 + height: 1500 + grid_size: 20 + auto_expand_vertically: true + block v_0m6g { + position: pos(20, 100, 1260, 680) + layer: 1 + } + block f_nfvl { + position: pos(20, 20, 300, 80) + layer: 2 + } + block f_dtbw { + position: pos(340, 20, 300, 80) + layer: 3 + } + block v_sfkb { + position: pos(20, 800, 1260, 680) + layer: 4 + } + mobile { + mode: 'auto' + } } - block f_dtbw { - position: pos(340, 20, 300, 80) - layer: 3 + tab tab2: CanvasLayout { + label: 'Tab 2' + width: 2000 + height: 800 + grid_size: 20 + auto_expand_vertically: true + mobile { + mode: 'auto' + } } } @@ -119,6 +186,7 @@ Dashboard chinh_sandbox { value: [] } } + block v_sfkb: block_chinh_test_table() interactions: [ FilterInteraction { from: 'f_nfvl' diff --git a/team-folders/Chinh/dashboards/chinh_template.page.aml b/team-folders/Chinh/dashboards/chinh_template.page.aml new file mode 100644 index 0000000..e991504 --- /dev/null +++ b/team-folders/Chinh/dashboards/chinh_template.page.aml @@ -0,0 +1,53 @@ +Dashboard chinh_template { + title: 'chinh_template' + description: '' + owner: 'chinh.dm@holistics.io' + + view: CanvasLayout { + label: 'View 1' + width: 1300 + height: 675 + grid_size: 25 + auto_expand_vertically: true + mobile { + mode: 'auto' + } + auto_expand_horizontally: true + block v_lm5d { + position: pos(25, 125, 1250, 525) + layer: 1 + } + } + + theme: H.themes.vanilla + block v_lm5d: VizBlock { + label: 'Total Value by Month' + viz: AreaChart { + dataset: chinh_dynamic_dataset + x_axis: VizFieldFull { + ref: r(chinh_dynamic_dim_model.order_created_at) + transformation: 'datetrunc month' + format { + type: 'date' + pattern: 'LLL yyyy' + } + } + y_axis { + series { + field: r(chinh_dynamic_dataset.total_value) + settings { + color_palette: 0 + } + } + } + settings { + row_limit: 5000 + x_axis_show_null_datetime: false + aggregate_awareness { + enabled: true + debug_comments: true + } + } + } + } +} \ No newline at end of file diff --git a/team-folders/Chinh/datasets/ticket_23584.dataset.aml b/team-folders/Chinh/datasets/ticket_23584.dataset.aml index f7e9d7e..5a157b7 100644 --- a/team-folders/Chinh/datasets/ticket_23584.dataset.aml +++ b/team-folders/Chinh/datasets/ticket_23584.dataset.aml @@ -1,13 +1,21 @@ Dataset ticket_23584 { label: 'ticket_23584' - description: '' + description: ''' +In the dashboard, which includes a Category filter, only display categories that have had non-zero sales in the last 2 years, +so users aren't forced to scroll through outdated or irrelevant categories. + +"Unused categories" = categories with 0 total sales amount over the past 2 years +=> 1. Filtering logic: total sales amount over the past 2 years +=> 2. Roll it up to the Dim Category's grain +=> 3. Then apply a case when to take the categories' name, Active Category +''' data_source_name: 'demodb' models: [ chinh_dim_date, chinh_dim_category, chinh_dim_product, - chinh_fact_sales + chinh_fact_sales, ] relationships: [ @@ -19,10 +27,12 @@ Dataset ticket_23584 { metric total_amount { label: 'Total Amount' type: 'number' - definition: @aql sum(chinh_fact_sales.sales_amount) ;; + definition: @aql + coalesce(sum(chinh_fact_sales.sales_amount), 0) + ;; } - dimension amount_per_product_ordered_within_2_years { + dimension amount_per_product_ordered_within_2_years { // calculated field model: chinh_dim_category label: 'Amount per Products (ordered within 2 years)' type: 'number' @@ -42,7 +52,7 @@ Dataset ticket_23584 { definition: @aql case( when: chinh_dim_category.amount_per_product_ordered_within_2_years > 0, - then: chinh_dim_category.category, + then: chinh_dim_category.category, // category name else: null ) From ddaaa7e8cbd26559c1d2c0d0a98a85511d520ce5 Mon Sep 17 00:00:00 2001 From: Chinh Date: Fri, 28 Nov 2025 07:47:11 +0000 Subject: [PATCH 3/8] Convert 'chinh_template' dashboard view to TabLayout with two tabs and layout adjustments --- .../Chinh/dashboards/chinh_template.page.aml | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/team-folders/Chinh/dashboards/chinh_template.page.aml b/team-folders/Chinh/dashboards/chinh_template.page.aml index e991504..facb445 100644 --- a/team-folders/Chinh/dashboards/chinh_template.page.aml +++ b/team-folders/Chinh/dashboards/chinh_template.page.aml @@ -3,19 +3,32 @@ Dashboard chinh_template { description: '' owner: 'chinh.dm@holistics.io' - view: CanvasLayout { + view: TabLayout { label: 'View 1' - width: 1300 - height: 675 - grid_size: 25 - auto_expand_vertically: true - mobile { - mode: 'auto' + tab tab1: CanvasLayout { + label: 'Tab 1' + width: 1300 + height: 675 + grid_size: 25 + auto_expand_vertically: true + auto_expand_horizontally: true + block v_lm5d { + position: pos(25, 125, 1250, 525) + layer: 1 + } + mobile { + mode: 'auto' + } } - auto_expand_horizontally: true - block v_lm5d { - position: pos(25, 125, 1250, 525) - layer: 1 + tab tab2: CanvasLayout { + label: 'Tab 2' + width: 1300 + height: 800 + grid_size: 20 + auto_expand_vertically: true + mobile { + mode: 'auto' + } } } From 79ffa6cb92bcc0161b00baf4bd7ec4cc24ce517e Mon Sep 17 00:00:00 2001 From: Chinh Date: Fri, 28 Nov 2025 07:50:10 +0000 Subject: [PATCH 4/8] Add 't_uu5o' TextBlock to 'chinh_template' and create 'derived_chinh_template' extension --- team-folders/Chinh/dashboards/chinh_template.page.aml | 7 +++++++ .../Chinh/dashboards/derived_chinh_template.page.aml | 1 + 2 files changed, 8 insertions(+) create mode 100644 team-folders/Chinh/dashboards/derived_chinh_template.page.aml diff --git a/team-folders/Chinh/dashboards/chinh_template.page.aml b/team-folders/Chinh/dashboards/chinh_template.page.aml index facb445..f036a46 100644 --- a/team-folders/Chinh/dashboards/chinh_template.page.aml +++ b/team-folders/Chinh/dashboards/chinh_template.page.aml @@ -16,6 +16,10 @@ Dashboard chinh_template { position: pos(25, 125, 1250, 525) layer: 1 } + block t_uu5o { + position: pos(25, 25, 425, 50) + layer: 2 + } mobile { mode: 'auto' } @@ -63,4 +67,7 @@ Dashboard chinh_template { } } } + block t_uu5o: TextBlock { + content: @md This is the template dashboard.;; + } } \ No newline at end of file diff --git a/team-folders/Chinh/dashboards/derived_chinh_template.page.aml b/team-folders/Chinh/dashboards/derived_chinh_template.page.aml new file mode 100644 index 0000000..114c20e --- /dev/null +++ b/team-folders/Chinh/dashboards/derived_chinh_template.page.aml @@ -0,0 +1 @@ +PartialDashboard derived_chinh_template = chinh_template.extend({}) \ No newline at end of file From 2b20ac92d8907133327c6581e37f2f2e30b30528 Mon Sep 17 00:00:00 2001 From: Chinh Date: Tue, 9 Dec 2025 10:08:23 +0000 Subject: [PATCH 5/8] Add model 'chinh_23949' and dataset 'chinh_23949_dataset' with conversion metrics and dimensions --- .../datasets/chinh_23949_dataset.dataset.aml | 28 +++++++ .../Chinh/models/chinh_23949.model.aml | 75 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml create mode 100644 team-folders/Chinh/models/chinh_23949.model.aml diff --git a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml new file mode 100644 index 0000000..b68beb1 --- /dev/null +++ b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml @@ -0,0 +1,28 @@ +Dataset chinh_23949_dataset { + label: 'chinh_23949_dataset' + description: '' + data_source_name: 'demodb' + models: [ + chinh_23949 + ] + relationships: [] + dimension is_user_converted { + label: "Is User Converted" + type: "number" + description: "" + definition: @aql dimensionalize( + count_if(chinh_23949.order_id is not null) + , chinh_23949.user_agent_id +);; + model: chinh_23949 + } + metric conversion_rate { + label: "Conversion Rate" + type: "number" + description: "" + definition: @aql safe_divide( + count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1), + count_distinct(chinh_23949.user_agent_id) +);; + } +} \ No newline at end of file diff --git a/team-folders/Chinh/models/chinh_23949.model.aml b/team-folders/Chinh/models/chinh_23949.model.aml new file mode 100644 index 0000000..653445d --- /dev/null +++ b/team-folders/Chinh/models/chinh_23949.model.aml @@ -0,0 +1,75 @@ +Model chinh_23949 { + type: 'query' + label: 'Chinh 23949' + description: '' + data_source_name: 'demodb' + dimension user_agent_id { + label: 'User Agent Id' + type: 'text' + hidden: false + definition: @sql {{ #SOURCE.user_agent_id }};; + } + dimension event_name { + label: 'Event Name' + type: 'text' + hidden: false + definition: @sql {{ #SOURCE.event_name }};; + } + dimension order_id { + label: 'Order Id' + type: 'text' + hidden: false + definition: @sql {{ #SOURCE.order_id }};; + } + + owner: 'chinh.dm@holistics.io' + query: @sql + WITH raw_table AS ( + -- USER 1001 (Converter - Used Recs) + SELECT 'u_1001' AS user_agent_id, 'view_homepage' AS event_name, NULL AS order_id UNION ALL + SELECT 'u_1001', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1001', 'add_to_cart', NULL UNION ALL + SELECT 'u_1001', 'purchase', 'ord_5501' UNION ALL + + -- USER 1002 (Non-Converter - Browse Only) + SELECT 'u_1002', 'view_homepage', NULL UNION ALL + SELECT 'u_1002', 'search_items', NULL UNION ALL + + -- USER 1003 (Converter - Used Recs) + SELECT 'u_1003', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1003', 'add_to_cart', NULL UNION ALL + SELECT 'u_1003', 'purchase', 'ord_5502' UNION ALL + + -- USER 1004 (Converter - Direct Purchase, NO Recs) -> Excluded from Denominator (User Pool) + SELECT 'u_1004', 'view_homepage', NULL UNION ALL + SELECT 'u_1004', 'view_product', NULL UNION ALL + SELECT 'u_1004', 'purchase', 'ord_5503' UNION ALL + + -- USER 1005 (Non-Converter - High Intent, Used Recs) -> Included in Denominator, Excluded from Numerator (Order Count) + SELECT 'u_1005', 'complete_style_quiz', NULL UNION ALL + SELECT 'u_1005', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1005', 'add_to_cart', NULL UNION ALL + + -- USER 1006 (Converter - Used Recs) + SELECT 'u_1006', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1006', 'purchase', 'ord_5504' UNION ALL + + -- USER 1007 (Non-Converter - High Intent, Used Recs) + SELECT 'u_1007', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1007', 'view_product', NULL UNION ALL + + -- USER 1008 (Converter - Used Recs for a second time) + SELECT 'u_1008', 'view_product', NULL UNION ALL + SELECT 'u_1008', 'view_outfit_recommendation', NULL UNION ALL + SELECT 'u_1008', 'purchase', 'ord_5505' UNION ALL + + -- USER 1009 (Non-Converter - Did NOT use Recs) + SELECT 'u_1009', 'view_category_shoes', NULL UNION ALL + SELECT 'u_1009', 'view_product', NULL UNION ALL + SELECT 'u_1009', 'add_to_cart', NULL + ) + SELECT * FROM raw_table + ;; + models: [ + ] +} From abb5ab6d33610fe9cdbaeaa4016553868d9ae177 Mon Sep 17 00:00:00 2001 From: Chinh Date: Tue, 9 Dec 2025 10:13:03 +0000 Subject: [PATCH 6/8] Add metrics 'conversion_rate', 'list_user_id', 'nominator', and 'denominator' to 'chinh_23949_dataset' and fix hidden property --- .../datasets/chinh_23949_dataset.dataset.aml | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml index b68beb1..2ae5fb7 100644 --- a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml +++ b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml @@ -6,6 +6,7 @@ Dataset chinh_23949_dataset { chinh_23949 ] relationships: [] + dimension is_user_converted { label: "Is User Converted" type: "number" @@ -16,13 +17,37 @@ Dataset chinh_23949_dataset { );; model: chinh_23949 } + metric conversion_rate { label: "Conversion Rate" type: "number" + hidden: false description: "" definition: @aql safe_divide( - count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1), + coalesce(count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1), 0), count_distinct(chinh_23949.user_agent_id) );; } + + metric list_user_id { + label: "List User Id" + type: "json" + description: "" + definition: @aql unique(chinh_23949.user_agent_id);; + } + + metric nominator { + label: "Nominator" + type: "number" + hidden: false + description: "" + definition: @aql coalesce(count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1), 0);; + } + + metric denominator { + label: "Denominator" + type: "number" + description: "" + definition: @aql count_distinct(chinh_23949.user_agent_id);; + } } \ No newline at end of file From 5d33c80b1baacd311b0e3ef17ef750755a3a814c Mon Sep 17 00:00:00 2001 From: Chinh Date: Tue, 9 Dec 2025 15:28:54 +0000 Subject: [PATCH 7/8] Add primary key to 'User Agent Id' and unhide 'Is User Converted' dimension in 'chinh_23949_dataset' --- team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml | 2 +- team-folders/Chinh/models/chinh_23949.model.aml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml index 2ae5fb7..06f1c0d 100644 --- a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml +++ b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml @@ -6,10 +6,10 @@ Dataset chinh_23949_dataset { chinh_23949 ] relationships: [] - dimension is_user_converted { label: "Is User Converted" type: "number" + hidden: false description: "" definition: @aql dimensionalize( count_if(chinh_23949.order_id is not null) diff --git a/team-folders/Chinh/models/chinh_23949.model.aml b/team-folders/Chinh/models/chinh_23949.model.aml index 653445d..79004a2 100644 --- a/team-folders/Chinh/models/chinh_23949.model.aml +++ b/team-folders/Chinh/models/chinh_23949.model.aml @@ -7,6 +7,7 @@ Model chinh_23949 { label: 'User Agent Id' type: 'text' hidden: false + primary_key: true definition: @sql {{ #SOURCE.user_agent_id }};; } dimension event_name { From 8bf18ba1f8505c5fadc379bae6f024ca081e1d60 Mon Sep 17 00:00:00 2001 From: Chinh Date: Mon, 15 Dec 2025 09:25:43 +0000 Subject: [PATCH 8/8] Add relationship and new metric 'old_conversion_rate' to 'chinh_23949_dataset' and adjust model 'chinh_23949' dimensions --- .../datasets/chinh_23949_dataset.dataset.aml | 38 ++++++++++++++----- .../Chinh/models/chinh_23949.model.aml | 5 ++- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml index 06f1c0d..9cee35d 100644 --- a/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml +++ b/team-folders/Chinh/datasets/chinh_23949_dataset.dataset.aml @@ -5,16 +5,22 @@ Dataset chinh_23949_dataset { models: [ chinh_23949 ] - relationships: [] + + relationships: [ + relationship(chinh_23949.user_agent_id - chinh_23949.user_agent_id, false) + ] + dimension is_user_converted { label: "Is User Converted" type: "number" hidden: false description: "" - definition: @aql dimensionalize( - count_if(chinh_23949.order_id is not null) - , chinh_23949.user_agent_id -);; + definition: @aql + dimensionalize( + count_if(chinh_23949.order_id is not null) + , chinh_23949.user_agent_id + ) + ;; model: chinh_23949 } @@ -23,10 +29,15 @@ Dataset chinh_23949_dataset { type: "number" hidden: false description: "" - definition: @aql safe_divide( - coalesce(count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1), 0), - count_distinct(chinh_23949.user_agent_id) -);; + definition: @aql + safe_divide( + coalesce( + count_distinct(chinh_23949.user_agent_id) | where(chinh_23949.is_user_converted == 1) + , 0 + ) + , count_distinct(chinh_23949.user_agent_id) + ) + ;; } metric list_user_id { @@ -50,4 +61,13 @@ Dataset chinh_23949_dataset { description: "" definition: @aql count_distinct(chinh_23949.user_agent_id);; } + metric old_conversion_rate { + label: "Old Conversion Rate" + type: "number" + description: "" + definition: @aql safe_divide( + count_distinct(chinh_23949.order_id) * 1.0, + count_distinct(chinh_23949.user_agent_id) +);; + } } \ No newline at end of file diff --git a/team-folders/Chinh/models/chinh_23949.model.aml b/team-folders/Chinh/models/chinh_23949.model.aml index 79004a2..ebd8de0 100644 --- a/team-folders/Chinh/models/chinh_23949.model.aml +++ b/team-folders/Chinh/models/chinh_23949.model.aml @@ -6,9 +6,10 @@ Model chinh_23949 { dimension user_agent_id { label: 'User Agent Id' type: 'text' + description: "" hidden: false - primary_key: true definition: @sql {{ #SOURCE.user_agent_id }};; + primary_key: true } dimension event_name { label: 'Event Name' @@ -73,4 +74,4 @@ Model chinh_23949 { ;; models: [ ] -} +} \ No newline at end of file