From 43b21d437708a14f020772f923e0d2a2c3f66f23 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Tue, 19 Mar 2024 20:43:09 +0000 Subject: [PATCH 01/16] balance sheet updates for Cortex release v5_4 --- ...eet_mktplace_report_table.dashboard.lookml | 156 +-------- ...nce_sheet_subtotal3_table.dashboard.lookml | 108 ++++++ ...otal3_table_no_comparison.dashboard.lookml | 56 ++++ ...> balance_sheet_template.dashboard.lookml} | 118 ++----- .../balance_sheet.explore.lkml | 38 ++- .../fiscal_periods_sdt.explore.lkml | 6 - manifest.lkml | 44 +-- ...balance_sheet_fiscal_periods_sdt.view.lkml | 45 +++ ...heet_fiscal_periods_selected_sdt.view.lkml | 195 +++++++++++ ...ce_sheet_hierarchy_selection_sdt.view.lkml | 256 +++++--------- views/balance_sheet_navigation_ext.view.lkml | 143 ++++++++ .../balance_sheet_path_to_node_pdt.view.lkml | 66 ++-- views/balance_sheet_rfn.view.lkml | 313 +++--------------- views/common_fields_finance_ext.view.lkml | 184 ++++++++++ ...mon_hierarchy_fields_finance_ext.view.lkml | 134 ++++++++ views/navigation_template.view.lkml | 280 ++++++++++++++++ views/universal_ledgers_md_base.view.lkml | 76 +++++ views/universal_ledgers_md_rfn.view.lkml | 38 +++ 18 files changed, 1519 insertions(+), 737 deletions(-) create mode 100644 LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml create mode 100644 LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml rename LookML_Dashboard/{balance_sheet_subtotal_table.dashboard.lookml => balance_sheet_template.dashboard.lookml} (50%) delete mode 100644 explores_balance_sheet/fiscal_periods_sdt.explore.lkml create mode 100644 views/balance_sheet_fiscal_periods_sdt.view.lkml create mode 100644 views/balance_sheet_fiscal_periods_selected_sdt.view.lkml create mode 100644 views/balance_sheet_navigation_ext.view.lkml create mode 100644 views/common_fields_finance_ext.view.lkml create mode 100644 views/common_hierarchy_fields_finance_ext.view.lkml create mode 100644 views/navigation_template.view.lkml create mode 100644 views/universal_ledgers_md_base.view.lkml create mode 100644 views/universal_ledgers_md_rfn.view.lkml diff --git a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml index 70028324..b6655d14 100644 --- a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml @@ -1,34 +1,19 @@ -# This dashboard requires the Report Table visualization (available for free on Looker Marketplace) to be installed. +#########################################################{ +# Balance Sheet financial report using Report Table visualization (available for free on Looker Marketplace) +# extends filters and title summary from balance_sheet_template +# customizations: +# - Balance Sheet table based on marketplace_viz_report_table::report_table-marketplace +#########################################################} - dashboard: balance_sheet_mktplace_report_table - title: Financial Statement - Balance Sheet + title: Financial Statement Balance Sheet layout: newspaper preferred_viewer: dashboards-next filters_location_top: false description: "Reports Fiscal Period Cumulative Amount in Global Currency for Levels 3 and 4 of the selected hierarchy, chart of accounts, company, fiscal period and comparison period (if any). Requires Report Table visualization to be downloaded from Looker Marketplace." + extends: balance_sheet_template elements: - - title: Summary Title - name: Summary Title - explore: balance_sheet - type: single_value - fields: [balance_sheet.title_balance_sheet] - filters: - balance_sheet.level_number: '3,4' - custom_color_enabled: true - show_single_value_title: false - show_comparison: false - listen: - Currency: balance_sheet.target_currency_tcurr - Chart of Accounts: balance_sheet.chart_of_accounts - Company: balance_sheet.company_text - Fiscal Period: balance_sheet.select_fiscal_period - Hierarchy: balance_sheet.hierarchy_name - Ledger: balance_sheet.ledger_name - row: 0 - col: 0 - width: 18 - height: 2 - title: Balance Sheet name: Balance Sheet @@ -38,7 +23,8 @@ balance_sheet.total_cumulative_amount_in_global_currency, balance_sheet.fiscal_year_period, balance_sheet_hierarchy_selection_sdt.hier3_node_text] pivots: [balance_sheet.fiscal_year_period] - filters: {} + filters: + balance_sheet_fiscal_periods_selected_sdt.fiscal_period_group: "-NULL" sorts: [balance_sheet.fiscal_year_period desc, balance_sheet_hierarchy_selection_sdt.hier1_node_text, balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] total: true @@ -90,7 +76,6 @@ show_row_totals: true truncate_header: false minimum_column_width: 75 - listen: Fiscal Period: balance_sheet.select_fiscal_period Comparison Type: balance_sheet.select_comparison_type @@ -98,123 +83,10 @@ Hierarchy: balance_sheet.hierarchy_name Chart of Accounts: balance_sheet.chart_of_accounts Company: balance_sheet.company_text - Currency: balance_sheet.target_currency_tcurr - Ledger: balance_sheet.ledger_name - Top Hierarchy Level to Display: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level + Global Currency: balance_sheet.target_currency_tcurr + Ledger Name: universal_ledgers_md.ledger_id_name + Top Hierarchy Level: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level row: 2 col: 0 - width: 18 + width: 24 height: 13 - - - - filters: - - name: Fiscal Period - title: Fiscal Period - type: field_filter - # assumes as 12 month fiscal period that aligns with calendar. Will find last complete month and select period with same value - default_value: "{% if _user_attributes['sap_use_demo_data']=='Yes'%}{% assign ym = '2023.011'%}{%else%}{% assign intervalDays = 31 %}{% assign intervalSeconds = intervalDays | times: 86400 %}{% assign daysMinus31 = 'now' | date: '%s' | minus: intervalSeconds %}{% assign m = daysMinus31 | date: '%m' | prepend: '00' | slice: -3,3 %}{% assign ym = daysMinus31 | date: '%Y' | append: '.' | append: m %}{%endif%}{{ym}}" - allow_multiple_values: false - required: true - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.select_fiscal_period - - - name: Comparison Type - title: Comparison Type - type: field_filter - default_value: yoy - allow_multiple_values: false - required: true - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.select_comparison_type - - - name: Custom Comparison Period - title: Custom Comparison Period - type: field_filter - default_value: '' - allow_multiple_values: false - required: false - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.select_custom_comparison_period - - - name: Currency - title: Currency - type: field_filter - default_value: USD - allow_multiple_values: false - required: true - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.target_currency_tcurr - - - name: Hierarchy - title: Hierarchy - type: field_filter - default_value: FPA1 - allow_multiple_values: false - required: true - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.hierarchy_name - - - name: Chart of Accounts - title: Chart of Accounts - type: field_filter - default_value: "{% if _user_attributes['sap_sql_flavor']=='S4' %}{% assign coa = 'YCOA'%}{%else%}{% assign coa = 'CA01' %}{% endif %}{{coa}}" - allow_multiple_values: false - required: true - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - field: balance_sheet.chart_of_accounts - - - name: Company - title: Company - type: field_filter - default_value: "%CENTRAL%" - allow_multiple_values: false - required: true - ui_config: - type: advanced - display: popover - explore: balance_sheet - field: balance_sheet.company_text - - - name: Ledger - title: Ledger - type: field_filter - default_value: "0L - Leading Ledger" - allow_multiple_values: true - required: false - ui_config: - type: tag_list - display: inline - explore: balance_sheet - field: balance_sheet.ledger_name - - - name: Top Hierarchy Level to Display - title: Top Hierarchy Level to Display - type: field_filter - default_value: '2' - allow_multiple_values: false - required: false - ui_config: - type: dropdown_menu - display: inline - explore: balance_sheet - listens_to_filters: [] - field: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level diff --git a/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml new file mode 100644 index 00000000..488d8c7d --- /dev/null +++ b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml @@ -0,0 +1,108 @@ +#########################################################{ +# Balance Sheet financial report using Subtotals +# extends filters and title summary from balance_sheet_template +# customizations: +# - Comparison Type filter options set to only yoy, prior or custom (none removed as option) +# - Balance Sheet table based on looker_grid visualization type using derived amounts for +# reporting and comparison periods including derived differences (amount and %) +#########################################################} + +- dashboard: balance_sheet_subtotal3_table + title: Financial Statement Balance Sheet + layout: newspaper + preferred_viewer: dashboards-next + description: Using standard table with subtotals, reports Fiscal Period Cumulative + Amount in Global Currency for the selected hierarchy, chart + of accounts, company, fiscal period and comparison period (if any). + filters_location_top: false + extends: balance_sheet_template + + elements: + - title: Balance Sheet + name: Balance Sheet + explore: balance_sheet + type: looker_grid + fields: [balance_sheet_fiscal_periods_selected_sdt.reporting_period_amount_in_global_currency, balance_sheet_fiscal_periods_selected_sdt.comparison_period_amount_in_global_currency, + balance_sheet_fiscal_periods_selected_sdt.difference_value, balance_sheet_fiscal_periods_selected_sdt.difference_percent, balance_sheet_hierarchy_selection_sdt.hier1_node_text, + balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] + sorts: [balance_sheet_hierarchy_selection_sdt.hier1_node_text, balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] + subtotals: [balance_sheet_hierarchy_selection_sdt.hier1_node_text, balance_sheet_hierarchy_selection_sdt.hier2_node_text] + total: true + show_view_names: false + show_row_numbers: true + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: false + table_theme: white + limit_displayed_rows: false + enable_conditional_formatting: false + header_text_alignment: center + header_font_size: '12' + rows_font_size: '12' + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + show_sql_query_menu_options: false + show_totals: true + show_row_totals: true + truncate_header: false + title_hidden: true + minimum_column_width: 100 + series_labels: + balance_sheet_hierarchy_selection_sdt.hier1_node_text: ' ' + balance_sheet_hierarchy_selection_sdt.hier2_node_text: ' ' + balance_sheet_hierarchy_selection_sdt.hier3_node_text: ' ' + series_collapsed: + balance_sheet_hierarchy_selection_sdt.hier1_node_text: false + balance_sheet_hierarchy_selection_sdt.hier2_node_text: false + align: left + listen: + Fiscal Period: balance_sheet.select_fiscal_period + Comparison Type: balance_sheet.select_comparison_type + Custom Comparison Period: balance_sheet.select_custom_comparison_period + Hierarchy: balance_sheet.hierarchy_name + Chart of Accounts: balance_sheet.chart_of_accounts + Company: balance_sheet.company_text + Global Currency: balance_sheet.target_currency_tcurr + Ledger Name: universal_ledgers_md.ledger_id_name + Top Hierarchy Level: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level + row: 3 + col: 0 + width: 24 + height: 8 + + - title: navigation + name: navigation + explore: balance_sheet + type: single_value + fields: [balance_sheet_navigation_ext.navigation] + filters: + balance_sheet_navigation_ext.navigation_focus_page: '1' + balance_sheet_navigation_ext.navigation_style: 'small' + show_single_value_title: false + show_comparison: false + listen: + Fiscal Period: balance_sheet_navigation_ext.filter1 + Global Currency: balance_sheet_navigation_ext.filter2 + Hierarchy: balance_sheet_navigation_ext.filter3 + Chart of Accounts: balance_sheet_navigation_ext.filter4 + Company: balance_sheet_navigation_ext.filter5 + Ledger Name: balance_sheet_navigation_ext.filter6 + Top Hierarchy Level: balance_sheet_navigation_ext.filter7 + row: 11 + col: 0 + width: 24 + height: 1 + + filters: + - name: Comparison Type + title: Comparison Type + ui_config: + type: dropdown_menu + display: inline + # remove none option to avoid display issues with comparison and variance columns + options: + - yoy + - prior + - custom diff --git a/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml b/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml new file mode 100644 index 00000000..9e9b98a2 --- /dev/null +++ b/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml @@ -0,0 +1,56 @@ +#########################################################{ +# Balance Sheet financial report using Subtotals but without Comparison to year ago, prior or custom fiscal periods +# extends filters and title summary from balance_sheet_template +# also extends Balance Sheet Table visualization from balance_sheet_subtotal3_table +# customizations: +# - Comparison Type filter options set to none +# - Custom Comparison Period default value and options set to none +# - Removed comparison-related fields from Balance Sheet table +#########################################################} + +- dashboard: balance_sheet_subtotal3_table_no_comparison + title: Financial Statement Balance Sheet + layout: newspaper + preferred_viewer: dashboards-next + description: "Using standard table with subtotals, reports Fiscal Period Cumulative Amount in Global Currency for the selected hierarchy, chart of accounts, company, and fiscal period." + filters_location_top: false + extends: [balance_sheet_template, balance_sheet_subtotal3_table] + + filters: + - name: Comparison Type + title: Comparison Type + default_value: none + ui_config: + type: dropdown_menu + display: inline + # remove all options for comparisons + options: + - none + + - name: Custom Comparison Period + title: Custom Comparison Period + type: field_filter + default_value: 'None' + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + options: + - None + explore: balance_sheet + field: balance_sheet.select_custom_comparison_period + + elements: + - title: Balance Sheet + name: Balance Sheet + explore: balance_sheet + type: looker_grid + fields: [balance_sheet_fiscal_periods_selected_sdt.reporting_period_amount_in_global_currency, + balance_sheet_hierarchy_selection_sdt.hier1_node_text, + balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] + + - title: navigation + name: navigation + filters: + balance_sheet_navigation_ext.navigation_focus_page: '2' diff --git a/LookML_Dashboard/balance_sheet_subtotal_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_template.dashboard.lookml similarity index 50% rename from LookML_Dashboard/balance_sheet_subtotal_table.dashboard.lookml rename to LookML_Dashboard/balance_sheet_template.dashboard.lookml index 534c3e11..0e122efd 100644 --- a/LookML_Dashboard/balance_sheet_subtotal_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_template.dashboard.lookml @@ -1,11 +1,28 @@ -- dashboard: balance_sheet_subtotal3_table - title: Financial Statement - Balance Sheet +#########################################################{ +# Balance Sheet template which must be EXTENDED into another dashboard +# +# defines the following elements which can be shared across Balance Sheet-related dashboards: +# - Summary Title visualization which appears at top of Balance Sheet dashboards +# - Filters including default values: +# Fiscal Period +# Comparison Type +# Custom Comparison Period +# Global Currency +# Hierarchy +# Chart of Accounts +# Company +# Ledger Name +# Top Hierarchy Level +# +# The Elements and their properties can be EXTENDED into other dashboards and modified further as necessary +#########################################################} + +- dashboard: balance_sheet_template + title: Balance Sheet Template + description: "Template of filters and other shared elements between Balance Sheet dashboards. Must be extended into another dashboard." layout: newspaper preferred_viewer: dashboards-next - description: Using standard table with subtotals, reports Fiscal Period Cumulative - Amount in Global Currency for the selected hierarchy, chart - of accounts, company, fiscal period and comparison period (if any). - filters_location_top: false + extension: required elements: - title: Summary Title @@ -15,83 +32,27 @@ fields: [balance_sheet.title_balance_sheet] filters: balance_sheet.level_number: '3,4' + balance_sheet_fiscal_periods_selected_sdt.fiscal_period_group: 'Reporting' custom_color_enabled: true show_single_value_title: false show_comparison: false listen: - Currency: balance_sheet.target_currency_tcurr + Global Currency: balance_sheet.target_currency_tcurr Chart of Accounts: balance_sheet.chart_of_accounts Company: balance_sheet.company_text Fiscal Period: balance_sheet.select_fiscal_period Hierarchy: balance_sheet.hierarchy_name - Ledger: balance_sheet.ledger_name + Ledger Name: universal_ledgers_md.ledger_id_name row: 0 col: 0 width: 24 height: 3 - - title: Balance Sheet - name: Balance Sheet - explore: balance_sheet - type: looker_grid - fields: [balance_sheet.reporting_period_amount_in_global_currency, balance_sheet.comparison_period_amount_in_global_currency, - balance_sheet.difference_value, balance_sheet.difference_percent, balance_sheet_hierarchy_selection_sdt.hier1_node_text, - balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] - sorts: [balance_sheet_hierarchy_selection_sdt.hier1_node_text, balance_sheet_hierarchy_selection_sdt.hier2_node_text, balance_sheet_hierarchy_selection_sdt.hier3_node_text] - subtotals: [balance_sheet_hierarchy_selection_sdt.hier1_node_text, balance_sheet_hierarchy_selection_sdt.hier2_node_text] - - total: true - show_view_names: false - show_row_numbers: true - transpose: false - truncate_text: true - hide_totals: false - hide_row_totals: false - size_to_fit: false - table_theme: white - limit_displayed_rows: false - enable_conditional_formatting: false - header_text_alignment: center - header_font_size: '12' - rows_font_size: '12' - conditional_formatting_include_totals: false - conditional_formatting_include_nulls: false - show_sql_query_menu_options: false - show_totals: true - show_row_totals: true - truncate_header: false - title_hidden: true - minimum_column_width: 100 - series_labels: - balance_sheet_hierarchy_selection_sdt.hier1_node_text: ' ' - balance_sheet_hierarchy_selection_sdt.hier2_node_text: ' ' - balance_sheet_hierarchy_selection_sdt.hier3_node_text: ' ' - series_collapsed: - balance_sheet_hierarchy_selection_sdt.hier1_node_text: false - balance_sheet_hierarchy_selection_sdt.hier2_node_text: false - align: left - - # defaults_version: 1 - listen: - Fiscal Period: balance_sheet.select_fiscal_period - Comparison Type: balance_sheet.select_comparison_type - Custom Comparison Period: balance_sheet.select_custom_comparison_period - Hierarchy: balance_sheet.hierarchy_name - Chart of Accounts: balance_sheet.chart_of_accounts - Company: balance_sheet.company_text - Currency: balance_sheet.target_currency_tcurr - Ledger: balance_sheet.ledger_name - Top Hierarchy Level: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level - row: 3 - col: 0 - width: 24 - height: 13 - filters: - name: Fiscal Period title: Fiscal Period type: field_filter - # default assumes as 12 month fiscal period that aligns with calendar. Will find last complete month and select period with same value + # assumes as 12 month fiscal period that aligns with calendar. Will find last complete month and select period with same value default_value: "{% if _user_attributes['sap_use_demo_data']=='Yes'%}{% assign ym = '2023.011'%}{%else%}{% assign intervalDays = 31 %}{% assign intervalSeconds = intervalDays | times: 86400 %}{% assign daysMinus31 = 'now' | date: '%s' | minus: intervalSeconds %}{% assign m = daysMinus31 | date: '%m' | prepend: '00' | slice: -3,3 %}{% assign ym = daysMinus31 | date: '%Y' | append: '.' | append: m %}{%endif%}{{ym}}" allow_multiple_values: false required: true @@ -99,7 +60,6 @@ type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.select_fiscal_period - name: Comparison Type @@ -112,7 +72,6 @@ type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.select_comparison_type - name: Custom Comparison Period @@ -125,11 +84,10 @@ type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.select_custom_comparison_period - - name: Currency - title: Currency + - name: Global Currency + title: Global Currency type: field_filter default_value: USD allow_multiple_values: false @@ -138,7 +96,6 @@ type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.target_currency_tcurr - name: Hierarchy @@ -151,21 +108,18 @@ type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.hierarchy_name - name: Chart of Accounts title: Chart of Accounts type: field_filter - # default_value: YCOA - default_value: "{% if _user_attributes['sap_sql_flavor']=='S4' %}{% assign coa = 'YCOA'%}{%else%}{% assign coa = 'CA01' %}{% endif %}{{coa}}" + default_value: "{% if _user_attributes['sap_sql_flavor']=='S4' %}{% assign coa = 'YCOA'%}{%elsif _user_attributes['sap_sql_flavor']=='ECC'%}{% assign coa = 'CA01' %}{%else%}{%assign coa = 'something else'%}{% endif %}{{coa}}" allow_multiple_values: false required: true ui_config: type: dropdown_menu display: inline explore: balance_sheet - listens_to_filters: [] field: balance_sheet.chart_of_accounts - name: Company @@ -178,21 +132,19 @@ type: advanced display: popover explore: balance_sheet - listens_to_filters: [] field: balance_sheet.company_text - - name: Ledger - title: Ledger + - name: Ledger Name + title: Ledger Name type: field_filter - default_value: "0L - Leading Ledger" + default_value: "%0L%" allow_multiple_values: true required: false ui_config: type: tag_list - display: popover + display: inline explore: balance_sheet - listens_to_filters: [] - field: balance_sheet.ledger_name + field: universal_ledgers_md.ledger_id_name - name: Top Hierarchy Level title: Top Hierarchy Level diff --git a/explores_balance_sheet/balance_sheet.explore.lkml b/explores_balance_sheet/balance_sheet.explore.lkml index 1af30ed6..66793b7f 100644 --- a/explores_balance_sheet/balance_sheet.explore.lkml +++ b/explores_balance_sheet/balance_sheet.explore.lkml @@ -1,20 +1,18 @@ include: "/views/balance_sheet_rfn.view" include: "/views/language_map_sdt.view" +include: "/views/universal_ledgers_md_rfn.view" +include: "/views/balance_sheet_fiscal_periods_selected_sdt.view" include: "/views/balance_sheet_hierarchy_selection_sdt.view" +include: "/views/balance_sheet_navigation_ext.view" explore: balance_sheet { always_join: [language_map_sdt] - always_filter: {filters:[balance_sheet.hierarchy_name: "FPA1",balance_sheet.chart_of_accounts: "CA01",balance_sheet.company_text: "%CENTRAL%",balance_sheet.target_currency_tcurr: "USD"]} + always_filter: {filters:[balance_sheet.hierarchy_name: "",balance_sheet.chart_of_accounts: "",balance_sheet.company_text: "",balance_sheet.target_currency_tcurr: ""]} # always filter on: # - Client as defined with constant - # - if parameter select_fiscal_period is in the query, keep only rows where fiscal_period_group (Reporting/Comparison) is not null - sql_always_where: ${balance_sheet.client_mandt}='@{CLIENT}' - {% if balance_sheet.select_fiscal_period._in_query %} - and ${balance_sheet.fiscal_period_group} is not null - {% endif %} - ;; + sql_always_where: ${balance_sheet.client_mandt}='@{CLIENT}';; join: language_map_sdt { type: inner @@ -23,7 +21,26 @@ explore: balance_sheet { fields: [] } + join: universal_ledgers_md { + view_label: "Balance Sheet" + type: left_outer + relationship: many_to_one + sql_on: ${balance_sheet.client_mandt} = ${universal_ledgers_md.client_mandt} AND + ${balance_sheet.ledger_in_general_ledger_accounting} = ${universal_ledgers_md.ledger_rldnr} AND + ${balance_sheet.language_key_spras} = ${universal_ledgers_md.language_langu};; + } + + join: balance_sheet_fiscal_periods_selected_sdt { + type: inner + relationship: many_to_one + sql_on: ${balance_sheet.hierarchy_name} = ${balance_sheet_fiscal_periods_selected_sdt.hierarchy_name} AND + ${balance_sheet.company_code}= ${balance_sheet_fiscal_periods_selected_sdt.company_code} AND + ${balance_sheet.fiscal_year} = ${balance_sheet_fiscal_periods_selected_sdt.fiscal_year} AND + ${balance_sheet.fiscal_period} = ${balance_sheet_fiscal_periods_selected_sdt.fiscal_period};; + } + join: balance_sheet_hierarchy_selection_sdt { + view_label: "Balance Sheet" type: inner relationship: many_to_one sql_on: ${balance_sheet.client_mandt} = ${balance_sheet_hierarchy_selection_sdt.client_mandt} and @@ -31,6 +48,11 @@ explore: balance_sheet { ${balance_sheet.chart_of_accounts} = ${balance_sheet_hierarchy_selection_sdt.chart_of_accounts} and ${balance_sheet.language_key_spras} = ${balance_sheet_hierarchy_selection_sdt.language_key_spras} and ${balance_sheet.node} = ${balance_sheet_hierarchy_selection_sdt.node};; - } + + join: balance_sheet_navigation_ext { + view_label: "🔍 Filters & 🛠 Tools" + relationship: one_to_one + sql: ;; +} } diff --git a/explores_balance_sheet/fiscal_periods_sdt.explore.lkml b/explores_balance_sheet/fiscal_periods_sdt.explore.lkml deleted file mode 100644 index 2325166b..00000000 --- a/explores_balance_sheet/fiscal_periods_sdt.explore.lkml +++ /dev/null @@ -1,6 +0,0 @@ -include: "/views/fiscal_periods_sdt.view" - -explore: fiscal_periods_sdt { - description: "Fiscal Periods used for Filter Suggestions" - hidden: yes -} diff --git a/manifest.lkml b/manifest.lkml index 09fdae7f..f5c519fe 100644 --- a/manifest.lkml +++ b/manifest.lkml @@ -4,7 +4,7 @@ constant: CONNECTION_NAME { } constant: GCP_PROJECT { - value: "GCP Project ID" + value: "GCP Project Name" export: override_required } @@ -34,47 +34,5 @@ constant: negative_format { value: "{% if value < 0 %}

{{rendered_value}}

{% else %} {{rendered_value}} {% endif %}" } -# enter the max number of fiscal periods in a fiscal year. -# used to derive previous previous period when 1st period is selected -constant: max_fiscal_period { - value: "12" - -} - -# comparison period derived based on select_comparison_type parameter: -# if yoy then subtract year from period -# if prior then subtract 1 from period (if period = 01 or 001 then substract 1 year and use max_fiscal_period for period) -# if custom then use value from select_custom_comparison_period -# if none use '' -constant: derive_comparison_period { - value: "{% assign comparison_type = select_comparison_type._parameter_value %} - {% assign fp = select_fiscal_period._parameter_value %} - {% assign cp = select_custom_comparison_period._parameter_value %} - {% assign max_fp_size = '3' | times: 1 %} - {% assign max_fp_size_neg = max_fp_size | times: -1 %} - {% assign pad = '00' %} - - {% if comparison_type == 'custom' %} - {% if fp == cp %}{% assign comparison_type = 'none' %} - {% elsif cp == '' %}{% assign comparison_type = 'yoy' %} - {% endif %} - {% endif %} - - {% if comparison_type == 'prior' or comparison_type == 'yoy' %} - {% assign p_array = fp | split: '.' %} - {% if comparison_type == 'prior' %} - {% if p_array[1] == '001' %} - {% assign m = '@{max_fiscal_period}' | prepend: pad | slice: max_fp_size_neg, max_fp_size %}{% assign sub_yr = 1 %} - {% else %} - {% assign m = p_array[1] | times: 1 | minus: 1 | prepend: pad | slice: max_fp_size_neg, max_fp_size %}{% assign sub_yr = 0 %} - {% endif %} - {% else %} - {% assign m = p_array[1] %}{% assign sub_yr = 1 %} - {% endif %} - {% assign yr = p_array[0] | times: 1 | minus: sub_yr %} - {% assign cp = yr | append: '.'| append: m %} - {% elsif comparison_type == 'none' %} {% assign cp = '' %} - {% endif %}" -} #} end additional constants diff --git a/views/balance_sheet_fiscal_periods_sdt.view.lkml b/views/balance_sheet_fiscal_periods_sdt.view.lkml new file mode 100644 index 00000000..26f9fc54 --- /dev/null +++ b/views/balance_sheet_fiscal_periods_sdt.view.lkml @@ -0,0 +1,45 @@ +#########################################################{ +# Finds the Fiscal Years and Periods available in Balance Sheet +# +# derives the following fields which will be used to identify comparison period based on user selections +# in the view balance_sheet_fiscal_periods_selected: +# - fiscal_year_period +# - yoy_fiscal_period +# - prior_fiscal_year_period +# +# note, no dimensions or measure are defined as this view is only intended to be used as a reference in another view +#########################################################} + +view: balance_sheet_fiscal_periods_sdt { + derived_table: { + sql: + SELECT + CONCAT(hierarchy_name,company_code,fiscal_year,fiscal_period) AS unique_id, + hierarchy_name, + company_code, + fiscal_year, + -- fiscal_quarter, + fiscal_period, + CONCAT(fiscal_year,'.',fiscal_period) as fiscal_year_period, + --yoy and prior period + CONCAT(PARSE_NUMERIC(fiscal_year) - 1,'.',fiscal_period) AS yoy_fiscal_year_period, + LAG(CONCAT(fiscal_year,'.',fiscal_period)) OVER (PARTITION BY hierarchy_name, company_code ORDER BY fiscal_year, fiscal_period) AS prior_fiscal_year_period + FROM ( + SELECT + HierarchyName AS hierarchy_name, + CompanyCode AS company_code, + FiscalYear AS fiscal_year, + FiscalPeriod AS fiscal_period + FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet` + WHERE Client = '@{CLIENT}' + GROUP BY + hierarchy_name, + company_code, + fiscal_year, + fiscal_period + ) p + ;; + } + + +} \ No newline at end of file diff --git a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml new file mode 100644 index 00000000..5fc82f6c --- /dev/null +++ b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml @@ -0,0 +1,195 @@ +#########################################################{ +# Purpose: +# Takes user inputs from parameters to derive Reporting vs Comparison Period +# +# Keys to using this view: +# - View label is "Reporting vs. Comparison Period" +# - Fields are hidden by default so must change hidden: property to no to include in an explore +# - includes references to fields from view balance_sheet so always join this view to balance_sheet using an inner join on: +# hierarchy_name, company_code, fiscal_year, fiscal_period +# Note, the balance_sheet_fiscal_periods_sdt view already filters to the same Client id so it is not needed in the join. +# +# Steps taken: +# 1) Takes user inputs from parameters: +# balance_sheet.select_fiscal_period - user picks one fiscal period which becomes the "Reporting" period +# balance_sheet.select_compare_to - user picks to compare the Reporting period to either: same period a year ago, the prior fiscal period, a specific fiscal period or none +# balance_sheet.select_custom_comparison_period - if user picks a comparison to a custom fiscal period, user must select one fiscal period which becomes the "Comparison" period +# +# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters that returns +# two fiscal periods representing the "Reporting" and "Comparison" periods. View balance_sheet_fiscal_periods_sdt is the source. +# +# 3) Derives new dimensions: +# fiscal_period_group -- value of Reporting or Comparison +# alignment_group_name -- equals the value of the selected reporting period +# +# Derives these Measures to support Reporting vs. Comparison Period: +# reporting_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Reporting' +# comparison_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Comparison' +# difference_value -- reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency +# difference_percent -- (reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency) / abs(comparison_period_amount_in_global_currency) +# +#########################################################} + + +include: "/views/balance_sheet_fiscal_periods_sdt.view.lkml" + + +view: balance_sheet_fiscal_periods_selected_sdt { + label: "Reporting vs. Comparison Period" + fields_hidden_by_default: yes + + derived_table: { + sql: {% assign comparison_type = balance_sheet.select_comparison_type._parameter_value %} + {% assign fp = balance_sheet.select_fiscal_period._parameter_value %} + {% assign cp = balance_sheet.select_custom_comparison_period._parameter_value %} + {% if comparison_type == 'custom' %} + {% if fp == cp %}{% assign comparison_type = 'none' %} + {% elsif cp == '' %}{% assign comparison_type = 'yoy' %} + {% endif %} + {% endif %} + + {% if comparison_type == 'custom' %} + {% assign cp_list = cp | prepend: ",'" | append: "'" %} + {%else%}{% assign cp_list = ' ' %} + {% endif %} + + SELECT + fp.unique_id, + fp.hierarchy_name, + fp.company_code, + fp.fiscal_year, + fp.fiscal_period, + fp.fiscal_year_period, + CASE fp.fiscal_year_period + WHEN '{{fp}}' THEN 'Reporting' + ELSE 'Comparison' + END AS fiscal_period_group, + 1 AS alignment_group, + '{{fp}}' AS alignment_group_name + FROM ${balance_sheet_fiscal_periods_sdt.SQL_TABLE_NAME} fp + WHERE fiscal_year_period IN ('{{fp}}'{{cp_list}}) + {% if comparison_type == 'prior' or comparison_type == 'yoy' %} + OR fiscal_year_period IN + (SELECT {{comparison_type}}_fiscal_year_period + FROM ${balance_sheet_fiscal_periods_sdt.SQL_TABLE_NAME} + WHERE fiscal_year_period = '{{fp}}' ) + {% endif %} + ;; + } + +######################################################### +# Dimensions +# { + + dimension: unique_id { + type: string + primary_key: yes + sql: ${TABLE}.unique_id;; + } + + dimension: hierarchy_name { + type: string + sql: ${TABLE}.hierarchy_name;; + } + + dimension: company_code { + type: string + sql: ${TABLE}.company_code;; + } + + dimension: fiscal_year { + type: string + sql: ${TABLE}.fiscal_year;; + } + + dimension: fiscal_period { + type: string + sql: ${TABLE}.fiscal_period;; + } + + dimension: alignment_group_name { + type: string + sql: ${TABLE}.alignment_group_name;; + } + + dimension: fiscal_period_group { + type: string + hidden: no + sql: ${TABLE}.fiscal_period_group;; + } + + dimension: alignment_group { + type: number + sql: ${TABLE}.alignment_group ;; + } + +#########################################################} end dimensions + +######################################################### +# Reporting vs Comparison Period Measures +# { + + measure: reporting_period_amount_in_global_currency { + type: sum_distinct + sql_distinct_key: ${balance_sheet.key} ;; + view_label: "Reporting vs. Comparison Period" + label_from_parameter: balance_sheet.select_fiscal_period + description: "Cumulative Amount in Global Currency for the selected Fiscal Reporting Period" + sql: ${balance_sheet.cumulative_amount_in_target_currency} ;; + filters: [fiscal_period_group: "Reporting"] + value_format_name: millions_d1 + html: @{negative_format} ;; + } + + measure: comparison_period_amount_in_global_currency { + type: sum_distinct + sql_distinct_key: ${balance_sheet.key} ;; + view_label: "Reporting vs. Comparison Period" + label: "{% assign compare_to = balance_sheet.select_comparison_type._parameter_value %} + {% if balance_sheet.select_fiscal_period._in_query %} + {% if compare_to == 'custom' %}{% parameter balance_sheet.select_custom_comparison_period %} + {% elsif compare_to == 'prior' %} + {% assign fp = balance_sheet.select_fiscal_period._parameter_value | split: '.' %} + {% if fp[1] == '001'%}{% assign cp = 'Previous Fiscal Period'%} + {% else %}{% assign m = fp[1] | times: 1 | minus: 1 | prepend: '00' | slice: -3, 3 %}{% assign cp = fp[0] | append: '.' | append: m %} + {% endif %}{{cp}} + {% elsif compare_to == 'yoy' %} + {% assign fp = balance_sheet.select_fiscal_period._parameter_value | split: '.' %} + {% assign yr = fp[0] | times: 1 | minus: 1 %} + {% assign cp = yr | append: '.'| append: fp[1] %}{{cp}} + {% elsif compare_to == 'none' %} + {% endif %} + {% else %} Comparison Period Amount in Global Currency + {% endif %}" + description: "Cumulative Amount in Global Currency for the selected Fiscal Comparison Period" + sql: ${balance_sheet.cumulative_amount_in_target_currency} ;; + filters: [fiscal_period_group: "Comparison"] + value_format_name: millions_d1 + html: {% if balance_sheet.select_fiscal_period._in_query and balance_sheet.select_comparison_type._parameter_value == 'none' %} + {% else %}@{negative_format} + {% endif %};; + } + + measure: difference_value { + type: number + view_label: "Reporting vs. Comparison Period" + label: "Variance Amount" + description: "Reporting Period Amount minus Comparison Period Amount" + sql: ${reporting_period_amount_in_global_currency} - ${comparison_period_amount_in_global_currency} ;; + value_format_name: millions_d1 + html: @{negative_format} ;; + } + + measure: difference_percent { + type: number + view_label: "Reporting vs. Comparison Period" + label: "Variance %" + description: "Percentage Change between Reporting and Comparison Periods" + # note ABS in denominator because both numerator and denominator can both be negative. ABS allows further Decline between 2 negative numbers to show as negative + sql: SAFE_DIVIDE( (${reporting_period_amount_in_global_currency} - ${comparison_period_amount_in_global_currency}),ABS(${comparison_period_amount_in_global_currency})) ;; + value_format_name: percent_1 + html: @{negative_format} ;; + } + +#########################################################} end reporting metrics +} diff --git a/views/balance_sheet_hierarchy_selection_sdt.view.lkml b/views/balance_sheet_hierarchy_selection_sdt.view.lkml index 6ee177c7..5f54c774 100644 --- a/views/balance_sheet_hierarchy_selection_sdt.view.lkml +++ b/views/balance_sheet_hierarchy_selection_sdt.view.lkml @@ -4,198 +4,122 @@ # parameter_pick_start_level - select top level of hierarchy to show # parameter_pick_depth_level - how many levels should be shown (1 to 5 levels) # 2) Derives node_text and node values for hier1 to hier5 by placing the top level selected by user into hier_1 and subsequent levels into hier2 to hier5 -# 3) Filters to the last level selected by user. For example, if Top Level to Display of 2 and a depth of 3 is selected: -# level = 5 -# derived as: 0 (start) + 3 (depth) + 2 (adjustment because minimum level possible = 2) +# 3) Filters applied: +# first level of the hierarchy = top level selected AND +# (level number = last level selected by user OR +# level number < last level AND IsLeafNode = true) +# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level AND +# levels 2 and 3 where IsLeafNode = true will also be selected # # If more than 5 hierarchy levels are needed, update the parameter_pick_depth_level and add additional hierN dimensions for node and node_text # -######################################################### +# EXTENDED FIELDS +# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext and can be further customized for Balance Sheet reporting: +# parameter_pick_start_level +# parameter_pick_depth_level +# hier1_node_text ... hier5_node_text +# hier1_node ... hier5_node +# +# This view should be joined to balance sheet using an inner join on: +# client_mandt +# hierarchy_name +# chart_of_accounts +# language_key_spras +# node +#########################################################} include: "/views/balance_sheet_path_to_node_pdt.view" +include: "/views/common_hierarchy_fields_finance_ext.view" + view: balance_sheet_hierarchy_selection_sdt { - derived_table: { - sql: - {% assign start = parameter_pick_start_level._parameter_value | times: 1 | minus: 2 %} + extends: [common_hierarchy_fields_finance_ext] + label: "Balance Sheet" + fields_hidden_by_default: yes + + derived_table: { + sql: + {% assign top_level = parameter_pick_start_level._parameter_value | times: 1 %} + {% assign offset_start = top_level | minus: 2 %} {% assign depth = parameter_pick_depth_level._parameter_value | times: 1 | minus: 1 %} - select + {% assign last_level = top_level | plus: depth %} + SELECT h.Client, h.ChartOfAccounts, h.HierarchyName, LanguageKey_SPRAS, LevelNumber, LevelSequenceNumber, + IsLeafNode, Node, NodeText, NodeTextPath_String, NodePath_String, - NodeTextPath[SAFE_OFFSET({{start}})] AS hier1_node_text, - NodeTextPath[SAFE_OFFSET({{start | plus: 1}})] AS hier2_node_text, - NodeTextPath[SAFE_OFFSET({{start | plus: 2}})] AS hier3_node_text, - NodeTextPath[SAFE_OFFSET({{start | plus: 3}})] AS hier4_node_text, - NodeTextPath[SAFE_OFFSET({{start | plus: 4}})] AS hier5_node_text, - NodePath[SAFE_OFFSET({{start}})] AS hier1_node, - NodePath[SAFE_OFFSET({{start | plus: 1}})] AS hier2_node, - NodePath[SAFE_OFFSET({{start | plus: 2}})] AS hier3_node, - NodePath[SAFE_OFFSET({{start | plus: 3}})] AS hier4_node, - NodePath[SAFE_OFFSET({{start | plus: 4}})] AS hier5_node - from ${balance_sheet_path_to_node_pdt.SQL_TABLE_NAME} h - where - --filter to ending level as start + depth + 2 (add 2 as minimum level is 2) - --cap at Max Number of Levels if requested depth exceeds - LevelNumber = least({{start}} + {{depth}} + 2,MaxLevelNumber) + NodeTextPath[SAFE_OFFSET({{offset_start}})] AS hier1_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 1}})] AS hier2_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 2}})] AS hier3_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 3}})] AS hier4_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 4}})] AS hier5_node_text, + NodePath[SAFE_OFFSET({{offset_start}})] AS hier1_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 1}})] AS hier2_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 2}})] AS hier3_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 3}})] AS hier4_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 4}})] AS hier5_node, + NodeLevelPath[SAFE_OFFSET({{offset_start}})] as top_level_selected + FROM ${balance_sheet_path_to_node_pdt.SQL_TABLE_NAME} h + --WHERE LevelNumber = least({{last_level}},MaxLevelNumber) + WHERE NodeLevelPath[SAFE_OFFSET({{offset_start}})] = '{{top_level}}' + AND ( LevelNumber = least({{last_level}},MaxLevelNumber) OR + (LevelNumber < least({{last_level}},MaxLevelNumber) AND IsLeafNode = true) + ) ;; - } - - label: "Balance Sheet" - fields_hidden_by_default: yes - - parameter: parameter_pick_start_level { - hidden: no - type: unquoted - view_label: "🗓 Pick Fiscal Periods" - label: "Select Top Hierarchy Level to Display" - suggest_explore: balance_sheet - suggest_dimension: balance_sheet.level_string - default_value: "2" - } - - parameter: parameter_pick_depth_level { - hidden: no - type: unquoted - view_label: "🗓 Pick Fiscal Periods" - label: "Select Number of Hierarchy Levels to Display" - description: "Select number of hierarchy levels (1 to 5) to display" - allowed_value: {value: "1"} - allowed_value: {value: "2"} - allowed_value: {value: "3"} - allowed_value: {value: "4"} - allowed_value: {value: "5"} - default_value: "3" - } - - dimension: key { - hidden: yes - type: string - primary_key: yes - sql: concat(${client_mandt},${hierarchy_name},${chart_of_accounts},${language_key_spras},${node}) ;; - } - - dimension: client_mandt { - type: string - sql: ${TABLE}.client ;; - } - - dimension: chart_of_accounts { - type: string - sql: ${TABLE}.ChartOfAccounts ;; - } - - dimension: hierarchy_name { - type: string - sql: ${TABLE}.HierarchyName ;; - } - - dimension: language_key_spras { - type: string - sql: ${TABLE}.LanguageKey_SPRAS ;; - } - - dimension: level_number { - type: number - sql: ${TABLE}.LevelNumber ;; - } - - dimension: node { - type: string - sql: ${TABLE}.node ;; - } - - dimension: node_text { - type: string - sql: ${TABLE}.NodeText ;; - } - - dimension: node_text_path_string { - hidden: no - type: string - sql: ${TABLE}.NodeTextPath_String ;; - } - - dimension: node_path_string { - hidden: no - type: string - sql: ${TABLE}.NodePath_String ;; - } + } - dimension: hier1_node_text { - hidden: no - type: string - sql: ${TABLE}.hier1_node_text ;; - order_by_field: hier1_node - } + dimension: key { + hidden: yes + type: string + primary_key: yes + sql: CONCAT(${client_mandt},${hierarchy_name},${chart_of_accounts},${language_key_spras},${node}) ;; + } - dimension: hier2_node_text { - hidden: no - type: string - sql: ${TABLE}.hier2_node_text ;; - order_by_field: hier2_node - } + parameter: parameter_pick_start_level { + suggest_explore: balance_sheet + suggest_dimension: balance_sheet.level_string + } - dimension: hier3_node_text { - hidden: no - type: string - sql: ${TABLE}.hier3_node_text ;; - order_by_field: hier3_node - } + dimension: client_mandt { + type: string + sql: ${TABLE}.client ;; + } - dimension: hier4_node_text { - hidden: no - type: string - sql: ${TABLE}.hier4_node_text ;; - order_by_field: hier4_node - } + dimension: chart_of_accounts { + type: string + sql: ${TABLE}.ChartOfAccounts ;; + } - dimension: hier5_node_text { - hidden: no - type: string - sql: ${TABLE}.hier5_node_text ;; - order_by_field: hier5_node - } + dimension: hierarchy_name { + type: string + sql: ${TABLE}.HierarchyName ;; + } - dimension: hier1_node { - hidden: no - description: "First level of hierarchy to display" - type: string - sql: ${TABLE}.hier1_node ;; - } + dimension: language_key_spras { + type: string + sql: ${TABLE}.LanguageKey_SPRAS ;; + } - dimension: hier2_node { - hidden: no - description: "Second level of hierarchy to display" - type: string - sql: ${TABLE}.hier2_node ;; - } + dimension: level_number { + type: number + sql: ${TABLE}.LevelNumber ;; + } - dimension: hier3_node { - hidden: no - description: "Third level of hierarchy to display" - type: string - sql: ${TABLE}.hier3_node ;; - } + dimension: node { + type: string + sql: ${TABLE}.node ;; + } - dimension: hier4_node { - hidden: no - description: "Fourth level of hierarchy to display" - type: string - sql: ${TABLE}.hier4_node ;; - } + dimension: node_text { + type: string + sql: ${TABLE}.NodeText ;; + } - dimension: hier5_node { - hidden: no - description: "Fifth level of hierarchy to display" - type: string - sql: ${TABLE}.hier5_node ;; - } - } +} diff --git a/views/balance_sheet_navigation_ext.view.lkml b/views/balance_sheet_navigation_ext.view.lkml new file mode 100644 index 00000000..323a75d2 --- /dev/null +++ b/views/balance_sheet_navigation_ext.view.lkml @@ -0,0 +1,143 @@ +#########################################################{ +# Extends and modifies navigation_template to support navigation between +# related Balance Sheet Subtotal Dashboards: With Comparisons and No Comparisons +# +# One sets of LookML dashboards are included: +# - Subtotal Table With Comparisons (balance_sheet_subtotal3_table) +# and Without Comparisons (balance_sheet_subtotal3_table_no_comparison) +# +# Note, Marketplace dashboard handles no comparisons cleanly so no additonal dashboard needed +# +# Customizations: +# dash_bindings: added dashboard and link names +# filter_bindings: added 7 filters and corresponding URL values +# filter label URL format +# ------- --------------- --------------------- +# filter1 Fiscal Period Fiscal+Period +# filter2 Global Currency Global+Currency +# filter3 Hierarchy Hierarchy +# filter4 Chart of Accounts Chart+of+Accounts +# filter5 Company Company +# filter6 Ledger Name Ledger+Name +# filter7 Top Hierarchy Level Top+Hierarchy+Level +# +# tip: to find URL formats copy url for dashboard and review list of parameters after +# [dashboard name]? +# +# filter1 to filter7 filters: added labels as indicated above (NOTE: can optionally unhide) +# navigation_focus_page: confirmed allowed values of 1 or 2 +# added group_label = "Navigation" for parameters exposed in the Explore +# +# To use this view: +# 1) Add to an explore using a bare join +# explore: balance_sheet { +# join: balance_sheet_navigation_ext { +# view_label: "🔍 Filters & 🛠 Tools" +# relationship: one_to_one +# sql: ;; +# }} +# +# 2) Add Navigation dimension to Single Value Visualization and set these paramaters accordingly +# Navigation Style = small +# Navigation Focus Page = 1 (if adding to first dashboard listed, set to 2 if added viz to second dashboard) +# +# 3) Add Navigation visualization to balance_sheet_subtotal_table dashboard and set viz to listen to the dashboard filters +# +# Below is example Dashboard LookML generated: +# - title: navigation +# name: navigation +# explore: balance_sheet +# type: single_value +# fields: [balance_sheet_navigation_ext.navigation] +# filters: +# balance_sheet_navigation_ext.navigation_focus_page: '1' +# balance_sheet_navigation_ext.navigation_style: 'small' +# show_single_value_title: false +# show_comparison: false +# listen: +# Fiscal Period: balance_sheet_navigation_ext.filter1 +# Global Currency: balance_sheet_navigation_ext.filter2 +# Hierarchy: balance_sheet_navigation_ext.filter3 +# Chart of Accounts: balance_sheet_navigation_ext.filter4 +# Company: balance_sheet_navigation_ext.filter5 +# Ledger Name: balance_sheet_navigation_ext.filter6 +# Top Hierarchy Level: balance_sheet_navigation_ext.filter7 +#########################################################} + + +include: "/views/navigation_template.view" + +view: balance_sheet_navigation_ext { + extends: [navigation_template] + + dimension: dash_bindings { + hidden: yes + type: string + sql: 'balance_sheet_subtotal3_table|With Comparisons||balance_sheet_subtotal3_table_no_comparison|No Comparisons' ;; + } + + dimension: filter_bindings { + hidden: yes + type: string + # sql: 'filter1|Display+Timeframe' ;; + sql: 'filter1|Fiscal+Period||filter2|Global+Currency||filter3|Hierarchy||filter4|Chart+of+Accounts||filter5|Company||filter6|Ledger+Name||filter7|Top+Hierarchy+Level' ;; + } + + parameter: navigation_focus_page { + hidden: no + type: unquoted + group_label: "Navigation" + allowed_value: {value:"1"} + allowed_value: {value:"2"} + default_value: "1" + } + + parameter: navigation_style { + hidden: no + group_label: "Navigation" + } + + filter: filter1 { + hidden: yes + type: string + label: "Fiscal Period" + } + + filter: filter2 { + hidden: yes + type: string + label: "Global Currency" + } + + filter: filter3 { + hidden: yes + type: string + label: "Hierarchy" + } + + filter: filter4 { + hidden: yes + type: string + label: "Chart of Accounts" + } + + filter: filter5 { + hidden: yes + type: string + label: "Company" + } + + filter: filter6 { + hidden: yes + type: string + label: "Ledger Name" + } + + filter: filter7 { + hidden: yes + type: string + label: "Top Hierarchy Level" + } + + +} diff --git a/views/balance_sheet_path_to_node_pdt.view.lkml b/views/balance_sheet_path_to_node_pdt.view.lkml index b8f66330..bbe0f51e 100644 --- a/views/balance_sheet_path_to_node_pdt.view.lkml +++ b/views/balance_sheet_path_to_node_pdt.view.lkml @@ -23,11 +23,23 @@ view: balance_sheet_path_to_node_pdt { Parent, COALESCE(REGEXP_REPLACE(ParentText,'Non[- ]Current','Noncurrent'),Parent) AS ParentText, Node, - COALESCE(REGEXP_REPLACE(NodeText,'Non[- ]Current','Noncurrent'),Node) AS NodeText + COALESCE(REGEXP_REPLACE(NodeText,'Non[- ]Current','Noncurrent'),Node) AS NodeText, + IsLeafNode FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet` GROUP BY - 1, 2, 3, 4, 5, 6, 7, 8, 9 ), + Client, + ChartOfAccounts, + HierarchyName, + LanguageKey_SPRAS, + LevelNumber, + Parent, + COALESCE(REGEXP_REPLACE(ParentText,'Non[- ]Current','Noncurrent'),Parent), + Node, + COALESCE(REGEXP_REPLACE(NodeText,'Non[- ]Current','Noncurrent'),Node), + IsLeafNode + ), + iterations AS ( SELECT Client, @@ -35,31 +47,35 @@ view: balance_sheet_path_to_node_pdt { HierarchyName, LanguageKey_SPRAS, LevelNumber, + IsLeafNode, Node, NodeText, Parent, ParentText, 0 AS LevelSequenceNumber, nodeText AS NodeTextPath_String, - Node AS NodePath_String + Node AS NodePath_String, + CAST(LevelNumber as STRING) AS NodeLevelPath_String FROM n WHERE LevelNumber = 2 - UNION ALL - SELECT + UNION ALL + SELECT n.Client, n.ChartOfAccounts, n.HierarchyName, n.LanguageKey_SPRAS, n.LevelNumber, + n.IsLeafNode, n.Node, n.NodeText, n.Parent, n.ParentText, LevelSequenceNumber+1 AS LevelSequenceNumber, - CONCAT(NodeTextPath_String, '/',n.NodeText) AS NodeTextPath_String, - CONCAT(NodePath_String, '/',n.Node) AS NodePath_String + CONCAT(NodeTextPath_String, '-->',n.NodeText) AS NodeTextPath_String, + CONCAT(NodePath_String, '-->',n.Node) AS NodePath_String, + CONCAT(NodeLevelPath_String, '-->',CAST(n.LevelNumber AS STRING)) AS NodeLevelPath_String FROM n JOIN @@ -70,24 +86,26 @@ view: balance_sheet_path_to_node_pdt { AND i.ChartOfAccounts = n.ChartOfAccounts AND i.HierarchyName = n.HierarchyName AND i.LanguageKey_SPRAS = n.LanguageKey_SPRAS - ) - select Client, - ChartOfAccounts, - HierarchyName, - LanguageKey_SPRAS, - Node, - NodeText, - ParentText, - LevelNumber, - LevelSequenceNumber, - max(LevelNumber) over (partition by Client,ChartOfAccounts,HierarchyName) as MaxLevelNumber, - NodeTextPath_String, - NodePath_String, - split(NodeTextPath_String,'/') as NodeTextPath, - split(NodePath_String,'/') as NodePath - from iterations + ) + SELECT Client, + ChartOfAccounts, + HierarchyName, + LanguageKey_SPRAS, + IsLeafNode, + Node, + NodeText, + ParentText, + LevelNumber, + LevelSequenceNumber, + MAX(LevelNumber) OVER (PARTITION BY Client,ChartOfAccounts,HierarchyName) AS MaxLevelNumber, + NodeTextPath_String, + NodePath_String, + SPLIT(NodeTextPath_String,'-->') AS NodeTextPath, + SPLIT(NodePath_String,'-->') AS NodePath, + SPLIT(NodeLevelPath_String,'-->') AS NodeLevelPath + FROM iterations ;; } } -} +} \ No newline at end of file diff --git a/views/balance_sheet_rfn.view.lkml b/views/balance_sheet_rfn.view.lkml index e94d0b06..dfbe0b39 100644 --- a/views/balance_sheet_rfn.view.lkml +++ b/views/balance_sheet_rfn.view.lkml @@ -1,5 +1,5 @@ -######################################################### -# aggregation of Transactions by the following dimensions: +#########################################################{ +# balance_sheet view reflects an aggregation of Transactions by the following dimensions: # Client # Fiscal Year # Fiscal Period @@ -18,6 +18,9 @@ # Exchange Rate (based on last date in the period) # Avg Exchange Rate, Max Exchange Rate # +# Derives Current Ratio, Current Assets, and Current Liabilities using English-only terms found in Node (text). +# These should be edited as necessary to use Node (code) values instead text values to accomodate other languages. +# # To query this table, always include Fiscal Year and Fiscal Period as dimensions # and filter to: # - a single Client MANDT (handled with Constant defined in Manifest file) @@ -26,12 +29,21 @@ # - a single Hierarchy Name or Financial Statement Version # - a single Chart of Accounts # - a single Company -######################################################### +# +# EXTENDED FIELDS: +# Extends common dimensions found in both balance sheet and profit and loss using view common_fields_finance_ext +# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, +# fiscal_period, fiscal_quarter, fiscal_year and related fields +# Changes to these dimensions can be made in view common_fields_finance_ext if the changes are for both balance sheet and profit and loss; +# or customize these dimensions specifically for Balance Sheet in this view as needed +#########################################################} include: "/views/balance_sheet_base.view" +include: "/views/common_fields_finance_ext.view" view: +balance_sheet { + extends: [common_fields_finance_ext] dimension: key { primary_key: yes @@ -51,27 +63,27 @@ view: +balance_sheet { # # use parameter selections to define fiscal_period_group values of 'Reporting' or 'Comparison' # -# a sql_always_where clause defined at explore level will -# filter where fiscal_period_group is null if select_fiscal_period is in the query +# the inner join to balance_sheet_fiscal_periods_selected at explore level will +# filter to keep rows where fiscal_period_group is not null if select_fiscal_period is in the query ######################################################### parameter: select_fiscal_period { type: unquoted - view_label: "🗓 Pick Fiscal Periods" + view_label: "🔍 Filters & 🛠 Tools" description: "Select a Fiscal Period for Balance Sheet Reporting" - suggest_explore: fiscal_periods_sdt + # suggest_explore: balance_sheet_fiscal_periods_sdt suggest_dimension: fiscal_year_period } parameter: select_comparison_type { type: unquoted - view_label: "🗓 Pick Fiscal Periods" - description: "To include a comparison period in the Balance Sheet report, select the type of comparison to make--Same Period Last Year (default), Previous Fiscal Period or Custom. If Cusom is selected, select a Fiscal Period from Select Custom Comparison Period parameter." + view_label: "🔍 Filters & 🛠 Tools" + description: "When creating a Balance Sheet report, you can choose to compare the selected fiscal period to the previous year, previous fiscal period, or a custom period. If Custom is selected, select a Fiscal Period from the 'Select Custom Comparison Period' parameter." allowed_value: { label: "None" value: "none" } allowed_value: { - label: "Same Period Last Year" value: "yoy" + label: "Year Ago" value: "yoy" } allowed_value: { label: "Previous Fiscal Period" value: "prior" @@ -84,9 +96,9 @@ view: +balance_sheet { parameter: select_custom_comparison_period { type: unquoted - view_label: "🗓 Pick Fiscal Periods" - description: "When Comparison Type = Custom, you must select a Comparison Period. If no comparison period selected, Same Period Last Year will be used." - suggest_explore: fiscal_periods_sdt + view_label: "🔍 Filters & 🛠 Tools" + description: "When Comparison Type equals Custom, you must select a Comparison Period. If no comparison period selected, previous year will be used." + # suggest_explore: fiscal_periods_sdt suggest_dimension: fiscal_year_period } @@ -94,68 +106,16 @@ view: +balance_sheet { #} end Parameters ######################################################### -# Dimensions +# Hierarchy Dimensions #{ - dimension: client_mandt { - type: string - label: "Client" - sql: ${TABLE}.Client ;; - } - - dimension: language_key_spras { - label: "Language Key" - description: "Language used for text display of Company, Parent and/or Child Node" - } - - dimension: currency_key { - label: "Currency (Local)" - description: "Local Currency" - } - - dimension: target_currency_tcurr { - label: "Currency (Global)" - description: "Target or Global Currency to display in Balance Sheet" - } - dimension: hierarchy_name { - description: "Hierarchy Name is same as Financial Statement Version (FSV)" - } - - dimension: ledger_in_general_ledger_accounting { - label: "Ledger" - description: "Ledger in General Ledger Accounting" - sql: coalesce(${TABLE}.LedgerInGeneralLedgerAccounting,'0L') ;; - } - - dimension: ledger_name { - description: "Ledger in General Ledger Accounting" - # sql: if(${ledger_in_general_ledger_accounting} = '0L','Leading Ledger', ${ledger_in_general_ledger_accounting} );; - sql: case ${ledger_in_general_ledger_accounting} - when '0L' then '0L - Leading Ledger' - when '2L' then '2L - IFRS Non-leading Ledger' - when '0E' then '0E - Extension Ledger' - else ${ledger_in_general_ledger_accounting} end;; - order_by_field: ledger_in_general_ledger_accounting - } - - dimension: business_area { - sql: coalesce(${TABLE}.BusinessArea,'N/A') ;; - } - - dimension: company_code { - label: "Company (code)" - description: "Company Code" - } - - dimension: company_text { - label: "Company (text)" - description: "Company Name" + description: "Hierarchy Name or Financial Statement Version (FSV)" } dimension: parent { label: "Parent (code)" - description: "Parent (as ID or code) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Non-Current Assets." + description: "Parent (as ID or code) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Noncurrent Assets." } dimension: parent_text { @@ -163,188 +123,63 @@ view: +balance_sheet { label: "Parent (text)" description: "Parent (as text) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Non-Current Assets." # sql: coalesce(${TABLE}.ParentText,${TABLE}.Parent) ;; - sql: coalesce(regexp_replace(${TABLE}.ParentText,'Non[- ]Current','Noncurrent'),${TABLE}.Parent) ;; + sql: COALESCE(regexp_replace(${TABLE}.ParentText,'Non[- ]Current','Noncurrent'),${TABLE}.Parent) ;; order_by_field: parent } + dimension: parent_sort_order { type: string hidden: yes - sql: concat(${level_number},${parent}) ;; + sql: CONCAT(${level_number},${parent}) ;; } dimension: node { label: "Node (code)" - description: "Child Node (as an ID or code) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Non-Current Assets." + description: "Child Node (as an ID or code) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Noncurrent Assets." } dimension: node_text { type: string label: "Node (text)" - description: "Child Node (as text) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Non-Current Assets." - sql: coalesce(regexp_replace(${TABLE}.NodeText,'Non[- ]Current','Noncurrent'),${TABLE}.Node) ;; + description: "Child Node (as text) of Hierarchy. For example, Assets is Parent with multiple Child Nodes like Current Assets and Noncurrent Assets." + sql: COALESCE(regexp_replace(${TABLE}.NodeText,'Non[- ]Current','Noncurrent'),${TABLE}.Node) ;; order_by_field: node } dimension: level { hidden: yes - description: "Shows the Parent-Child Relationship. For example depending on the Hierarchy selected, Level 02 will display FPA1 as the Parent with Assets and Liabilities & Equity as Child Nodes. Level 03 will display Assets as Parent with Current Assets and Non-Current Assets as Child Nodes." + description: "The child node level displays the parent-child relationship. For instance at level 2, FPA1 is the parent with Assets and Liabilities & Equity as child nodes. At level 3, Assets is the parent with Current Assets and Noncurrent Assets as child nodes." } dimension: level_number { type: number - description: "Level as a numeric. Level shows the Parent-Child Relationship. For example depending on the Hierarchy selected, Level 2 will display FPA1 as the Parent with Assets and Liabilities & Equity as Child Nodes. Level 3 will display Assets as Parent with Current Assets and Non-Current Assets as Child Nodes." - sql: parse_numeric(${level}) ;; + description: "Level as a numeric. The child node level displays the parent-child relationship. For instance at level 2, FPA1 is the parent with Assets and Liabilities & Equity as child nodes. At level 3, Assets is the parent with Current Assets and Noncurrent Assets as child nodes." + sql: PARSE_NUMERIC(${level}) ;; } dimension: level_string { type: string label: "Level" - description: "Level as a numeric. Level shows the Parent-Child Relationship. For example depending on the Hierarchy selected, Level 2 will display FPA1 as the Parent with Assets and Liabilities & Equity as Child Nodes. Level 3 will display Assets as Parent with Current Assets and Non-Current Assets as Child Nodes." - sql: ltrim(${level},'0') ;; + description: "Level as a string without any leading 0s. The child node level displays the parent-child relationship. For instance at level 2, FPA1 is the parent with Assets and Liabilities & Equity as child nodes. At level 3, Assets is the parent with Current Assets and Noncurrent Assets as child nodes." + sql: LTRIM(${level},'0') ;; } dimension: is_leaf_node { - description: "Yes if GL Account Number and indicates lowest level of hierarchy." - } - - -# Fiscal Year and Period and other forms of Fiscal Dates -# { - dimension: fiscal_period { - group_label: "Fiscal Dates" - description: "Fiscal Period as 3-character string (e.g., 001)" - } - - dimension: fiscal_period_number { - hidden: yes - group_label: "Fiscal Dates" - description: "Fiscal Period as a Numeric Value" - type: number - sql: parse_numeric(${fiscal_period}) ;; - value_format_name: id - } - - dimension: fiscal_quarter { - group_label: "Fiscal Dates" - description: "Fiscal Quarter value of 1, 2, 3, or 4" - } - - dimension: fiscal_year { - group_label: "Fiscal Dates" - description: "Fiscal Year as YYYY" - } - - dimension: fiscal_year_period_number { - hidden: no - type: number - group_label: "Fiscal Dates" - description: "Fiscal Year and Period as a Numeric Value in form of YYYYPPP" - sql: parse_numeric(concat(${fiscal_year},${fiscal_period})) ;; - value_format_name: id - } - - # used in order_by_field to sort fiscal year period in descending order - dimension: fiscal_year_period_negative_number { - hidden: yes - type: number - sql: -1 * ${fiscal_year_period_number} ;; - } - - dimension: fiscal_year_period { - type: string - group_label: "Fiscal Dates" - description: "Fiscal Year and Period as String in form of YYYY.PPP" - sql: concat(${fiscal_year},'.',${fiscal_period});; - order_by_field: fiscal_year_period_negative_number - } - - dimension: fiscal_year_quarter { - type: string - group_label: "Fiscal Dates" - description: "Fiscal Year and Quater in form of YYYY.Q#" - sql: concat(${fiscal_year},'.Q',${fiscal_quarter}) ;; + description: "Yes if GL Account Number which indicates lowest level of hierarchy" } - dimension: fiscal_year_number { - hidden: yes - group_label: "Fiscal Dates" - description: "Fiscal Year as a Numeric Value" - type: number - sql: parse_numeric(${fiscal_year}) ;; - value_format_name: id - } - - # if select_fiscal_period parameter used in query, assign fiscal_year_period to either Reporting or Comparison group - # comparison period derived based on select_comparison_type parameter: - # if yoy then subtract year from period - # if prior then subtract 1 from period (if period 001 then substract 1 year and use max_fiscal_period for period) - # if custom then use value from select_custom_comparison_period - # see manifest for full logic defined in constant derive_comparison_period - - dimension: fiscal_period_group { - type: string - group_label: "Fiscal Dates" - description: "Fiscal Period is labeled either Reporting or Comparison depending on the values user picks for Fiscal Period and Comparison Type." - sql: {% if select_fiscal_period._in_query %} - @{derive_comparison_period} - - case when ${fiscal_year_period} = '{{fp}}' then 'Reporting' - {% if comparison_type != 'none' %} - when ${fiscal_year_period} = '{{cp}}' then 'Comparison' - {% endif %} - end - {% else %} 'No Fiscal Reporting Period has been selected. Add Select Fiscal Period parameter.' - {% endif %} - ;; - } - - dimension: selected_fiscal_reporting_period { - type: string - group_label: "Fiscal Dates" - description: "Fiscal Period chosen with parameter Select Fiscal Period" - sql: '{% parameter select_fiscal_period %}';; - } - - #} end Fiscal Dates - -# Hidden dimensions including those restated as measures like Amounts and Exchange Rates -# { - # hide client and define as client_mandt to match other SAP tables - dimension: client { - hidden: yes - } - - dimension: amount_in_local_currency { - hidden: yes - } - - dimension: amount_in_target_currency { - hidden: yes - label: "Amount in Global Currency" - } - - dimension: cumulative_amount_in_local_currency { - hidden: yes - } + #} end Hierarchy Dimensions - dimension: cumulative_amount_in_target_currency { - hidden: yes - label: "Cumulative Amount in Global Currency" - description: "End of Period Cumulative Amount in Global/Target Currency" - } - dimension: exchange_rate {hidden: yes} - dimension: avg_exchange_rate {hidden:yes} - dimension: max_exchange_rate {hidden:yes} -#} end hidden dimensions - -#} end Dimensions ######################################################### # Measures # { - measure: count {hidden: yes} + measure: count { + hidden: no + label: "Count of Rows" + } measure: total_amount_in_local_currency { type: sum @@ -395,62 +230,17 @@ view: +balance_sheet { measure: current_ratio { type: number description: "The ratio of current assets to current liabilities. Generally, a current ratio below 1 may be a warning sign that the company doesn’t have enough convertible assets to meet its short-term liabilities." - sql: safe_divide(${current_assets},${current_liabilities}) * -1;; + sql: SAFE_DIVIDE(${current_assets},${current_liabilities}) * -1;; value_format_name: decimal_2 } - measure: reporting_period_amount_in_global_currency { - type: sum - group_label: "Reporting v Comparison Period Metrics" - label_from_parameter: select_fiscal_period - description: "Cumulative Amount in Global Currency for the selected Fiscal Reporting Period" - sql: ${cumulative_amount_in_target_currency} ;; - filters: [fiscal_period_group: "Reporting"] - value_format_name: millions_d1 - html: @{negative_format} ;; - } - - # use sum(case ... when Comparison...) instead of type: sum with filter to allow nulls with Comparison is set to None - measure: comparison_period_amount_in_global_currency { - type: number - group_label: "Reporting v Comparison Period Metrics" - label: "{% if select_fiscal_period._in_query %} - @{derive_comparison_period}{{cp}} - {% else %} Comparison Period Amount in Global Currency - {% endif %}" - description: "Cumulative Amount in Global Currency for the selected Fiscal Comparison Period" - sql: sum(case ${fiscal_period_group} when "Comparison" then ${cumulative_amount_in_target_currency} else null end) ;; - value_format_name: millions_d1 - html: @{negative_format} ;; - } - - measure: difference_value { - type: number - group_label: "Reporting v Comparison Period Metrics" - label: "Gain (Loss)" - description: "Reporting Period Amount minus Comparison Period Amount" - sql: ${reporting_period_amount_in_global_currency} - ${comparison_period_amount_in_global_currency} ;; - value_format_name: millions_d1 - html: @{negative_format} ;; - } - - measure: difference_percent { - type: number - group_label: "Reporting v Comparison Period Metrics" - label: "Var %" - description: "Percentage Change between Reporting and Comparison Periods" - sql: safe_divide( (${reporting_period_amount_in_global_currency} - ${comparison_period_amount_in_global_currency}),abs(${comparison_period_amount_in_global_currency})) ;; - value_format_name: percent_1 - html: @{negative_format} ;; - } - # used in Balance Sheet dashboard; add to a single-value visualization measure: title_balance_sheet { type: number - description: "Used in Balance Sheet dashboard as Summary visualization with Company, Global Currency, Fiscal Period and Current Ratio." + description: "Used in Balance Sheet dashboard as Summary visualization with Company, Global Currency, Fiscal Period and Current Ratio. Add this measure to a single-value visualizaiton." sql: 1 ;; html: -
+
Balance Sheet
{{company_text._value}}
Fiscal Period: {{select_fiscal_period._parameter_value}}    Current Ratio: {{current_ratio._rendered_value}} @@ -487,13 +277,6 @@ view: +balance_sheet { value_format_name: decimal_4 } - measure: max_fiscal_year_period { - type: max - sql: ${fiscal_year_period_number} ;; - value_format_name: id - } - - #} end measures } diff --git a/views/common_fields_finance_ext.view.lkml b/views/common_fields_finance_ext.view.lkml new file mode 100644 index 00000000..992881db --- /dev/null +++ b/views/common_fields_finance_ext.view.lkml @@ -0,0 +1,184 @@ +#########################################################{ +# common fields and parameters to be EXTENDED into: +# balance_sheet_rfn +# profit_and_loss_rfn +# +# This view's established properties will be utilized by any views that use this view as an extension. +# Once extended into balance_sheet_rfn and profit_and_loss_rfn, these dimensions can be customized as necessary in the extending views. +# +# includes: +# client_mandt +# language_key_spras +# currency_key +# target_currency_tcurr +# ledger_in_general_ledger_accounting +# company_code +# company_text +# business_area +# chart_of_accounts +# fiscal_period, fiscal_period_number, fiscal_year_period, fiscal_year_period_number, fiscal_year_period_negative_number +# fiscal_quarter, fiscal_quarter_label, fiscal_year_quarter_label, fiscal_year_quarter_negative_number +# fiscal_year, fiscal_year_number, fiscal_year_negative_number +# +# hidden dimensions: client, exchange_rate, avg_exchange_rate, amount_in_local_currency, amount_in_target_currency, amount_in_target_currency +# cumulative_amount_in_target_currency, cumulative_amount_in_target_currency +#########################################################} + + +view: common_fields_finance_ext { + + dimension: client_mandt { + type: string + hidden: yes + label: "Client" + description: "Client MANDT" + sql: ${TABLE}.Client ;; + } + + dimension: language_key_spras { + label: "Language Key" + description: "Language used for text display of Company, Parent and/or Child Node. Automatically filters to user's locale user attribute value." + } + + dimension: currency_key { + label: "Currency (Local)" + description: "Local Currency" + } + + dimension: target_currency_tcurr { + label: "Currency (Global)" + description: "Target or Global Currency to display" + } + + dimension: ledger_in_general_ledger_accounting { + label: "Ledger" + description: "Ledger in General Ledger Accounting as ID or Code" + sql: COALESCE(${TABLE}.LedgerInGeneralLedgerAccounting,'0L') ;; + } + + dimension: company_code { + label: "Company (code)" + description: "Company Code" + } + + dimension: company_text { + label: "Company (text)" + description: "Company Name" + } + + dimension: business_area { + description: "Business Area" + sql: COALESCE(${TABLE}.BusinessArea,'N/A') ;; + } + + dimension: chart_of_accounts { + description: "Chart of Accounts" + } + + # Fiscal Year and Period and other forms of Fiscal Dates + # { + dimension: fiscal_period { + group_label: "Fiscal Dates" + description: "Fiscal Period as 3-character string (e.g., 001)" + } + + dimension: fiscal_period_number { + hidden: yes + group_label: "Fiscal Dates" + description: "Fiscal Period as a Numeric Value" + type: number + sql: PARSE_NUMERIC(${fiscal_period}) ;; + value_format_name: id + } + + dimension: fiscal_year_period { + type: string + group_label: "Fiscal Dates" + description: "Fiscal Year and Period as String in form of YYYY.PPP" + sql: CONCAT(${fiscal_year},'.',${fiscal_period});; + order_by_field: fiscal_year_period_negative_number + } + + dimension: fiscal_year_period_number { + hidden: yes + type: number + label: "Fiscal Year Period (number)" + group_label: "Fiscal Dates" + description: "Fiscal Year and Period as a Numeric Value in form of YYYYPPP" + sql: PARSE_NUMERIC(CONCAT(${fiscal_year},${fiscal_period})) ;; + value_format_name: id + } + + dimension: fiscal_year_period_negative_number { + hidden: yes + type: number + sql: -1 * ${fiscal_year_period_number} ;; + } + + dimension: fiscal_quarter { + type: number + hidden: yes + label: "Fiscal Quarter (number)" + group_label: "Fiscal Dates" + description: "Fiscal Quarter value of 1, 2, 3, or 4" + sql: PARSE_NUMERIC(${TABLE}.FiscalQuarter) ;; + } + + dimension: fiscal_quarter_label { + group_label: "Fiscal Dates" + label: "Fiscal Quarter" + description: "Fiscal Quarter value of Q1, Q2, Q3, or Q4" + sql: CONCAT('Q',${TABLE}.FiscalQuarter);; + } + + dimension: fiscal_year_quarter_label { + group_label: "Fiscal Dates" + label: "Fiscal Year Quarter" + description: "Fiscal Quarter value with year in format YYYY.Q#" + sql: CONCAT(${fiscal_year},'.Q',${fiscal_quarter}) ;; + } + + dimension: fiscal_year_quarter_negative_number { + hidden: yes + type: number + sql: -1 * PARSE_NUMERIC(CONCAT(${fiscal_year},${fiscal_quarter})) ;; + } + + dimension: fiscal_year { + group_label: "Fiscal Dates" + description: "Fiscal Year as YYYY" + } + + dimension: fiscal_year_number { + hidden: yes + group_label: "Fiscal Dates" + label: "Fiscal Year (number)" + description: "Fiscal Year as a Numeric Value" + type: number + sql: PARSE_NUMERIC(${fiscal_year}) ;; + value_format_name: id + } + + dimension: fiscal_year_negative_number { + hidden: yes + type: number + sql: -1 * PARSE_NUMERIC(${fiscal_year}) ;; + } + +#} end fiscal period + +# Hidden dimensions that are restated as measures; Amounts and Exchange Rates +# { + # hide client and define as client_mandt to match other SAP tables + dimension: client {hidden: yes} + dimension: exchange_rate {hidden: yes} + dimension: avg_exchange_rate {hidden:yes} + dimension: max_exchange_rate {hidden:yes} + dimension: amount_in_local_currency {hidden: yes} + dimension: amount_in_target_currency {hidden: yes} + dimension: cumulative_amount_in_local_currency {hidden: yes} + dimension: cumulative_amount_in_target_currency {hidden: yes} + + #} end hidden dimensions + +} diff --git a/views/common_hierarchy_fields_finance_ext.view.lkml b/views/common_hierarchy_fields_finance_ext.view.lkml new file mode 100644 index 00000000..5d909e7b --- /dev/null +++ b/views/common_hierarchy_fields_finance_ext.view.lkml @@ -0,0 +1,134 @@ +#########################################################{ +# common hierarchy-related fields and parameters to be EXTENDED into: +# balance_sheet_hierarchy_selection_sdt +# profit_and_loss_hierarchy_selection_sdt +# +# This view's established properties will be utilized by any views that use this view as an extension. +# +#########################################################} + +view: common_hierarchy_fields_finance_ext { + extension: required + + parameter: parameter_pick_start_level { + hidden: no + type: unquoted + view_label: "🔍 Filters & 🛠 Tools" + label: "Select Top Hierarchy Level to Display" + description: "Specify the initial hierarchy level to be displayed. If the value is 3, the first three columns of the report will represent child hierarchy levels 3, 4, and 5. If the value is 6, the first three columns will represent levels 6, 7, 8." + # update suggest_explore and dimension after extending + # suggest_explore: balance_sheet + # suggest_dimension: balance_sheet.level_string + default_value: "2" + } + + parameter: parameter_pick_depth_level { + hidden: no + type: unquoted + view_label: "🔍 Filters & 🛠 Tools" + label: "Select Number of Hierarchy Levels to Display" + description: "Select number of hierarchy levels (1 to 5) to display" + allowed_value: {value: "1"} + allowed_value: {value: "2"} + allowed_value: {value: "3"} + allowed_value: {value: "4"} + allowed_value: {value: "5"} + default_value: "3" + } + + dimension: node_text_path_string { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Full Hierarchy Path" + sql: ${TABLE}.NodeTextPath_String ;; + } + + dimension: node_path_string { + hidden: yes + type: string + group_label: "Hierarchy Paths to Node" + label: "Full Hierarchy Path (code)" + sql: ${TABLE}.NodePath_String ;; + } + + dimension: hier1_node_text { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Hierarchy Node 1" + description: "Node (text) for 1st Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" + sql: ${TABLE}.hier1_node_text ;; + order_by_field: hier1_node + } + + dimension: hier2_node_text { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Hierarchy Node 2" + description: "Node (text) for 2nd Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" + sql: COALESCE(${TABLE}.hier2_node_text,' ') ;; + order_by_field: hier2_node + } + + dimension: hier3_node_text { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Hierarchy Node 3" + description: "Node (text) for 3rd Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" + sql: COALESCE(${TABLE}.hier3_node_text,' ') ;; + order_by_field: hier3_node + } + + dimension: hier4_node_text { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Hierarchy Node 4" + description: "Node (text) for 4th Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" + sql: COALESCE(${TABLE}.hier4_node_text, ' ') ;; + order_by_field: hier4_node + } + + dimension: hier5_node_text { + hidden: no + type: string + group_label: "Hierarchy Paths to Node" + label: "Hierarchy Node 5" + description: "Node (text) for 5th Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" + sql: COALESCE(${TABLE}.hier5_node_text,' ') ;; + order_by_field: hier5_node + } + + dimension: hier1_node { + hidden: yes + type: string + sql: ${TABLE}.hier1_node ;; + } + + dimension: hier2_node { + hidden: yes + type: string + sql: ${TABLE}.hier2_node ;; + } + + dimension: hier3_node { + hidden: yes + type: string + sql: ${TABLE}.hier3_node ;; + } + + dimension: hier4_node { + hidden: yes + type: string + sql: ${TABLE}.hier4_node ;; + } + + dimension: hier5_node { + hidden: yes + type: string + sql: ${TABLE}.hier5_node ;; + } +} diff --git a/views/navigation_template.view.lkml b/views/navigation_template.view.lkml new file mode 100644 index 00000000..a6b6852d --- /dev/null +++ b/views/navigation_template.view.lkml @@ -0,0 +1,280 @@ +#########################################################{ +# use this template to generate an html navigation bar, navigation tabs or simple navigation with small text +# this template can only be EXTENDED into another view +# +# this template provides three styles and up to 10 possible filters: +# horizontal bar with gray background and cortex image (set with parameter navigation_style = "bar") +# tabbed with cortex image (set with parameter navigation_style = "tabs") +# small text with links only and no image or formatting (set with parameter navigation_style = "small") +# +# modify this template if you want different styles or more filters +# +# extend this template into a view and customize for: +# list of dashboards (ids and names) +# list of filters (filter1, filter2, etc... with label used in dashboard filters) +# +# To extend this template: +# - create new view +# - add extend: parameter and reference this view (navigation_template) +# - required updates: +# - edit the sql: parameter of dash_bindings dimension with list of dashboard ids and names: +# for udd dashboards use numeric id: +# sql: '131|Dashboard 1||132|Dashboard 2' ;; +# +# for lookml dashboards use lookml dashboard name with or without model name: +# sql: 'dashboard_name1|Dashboard 1||dashboard_name2|Dashboard 2';; +# sql: 'model_name::dashboard_name1|Dashboard 1||model_name::dashboard_name2|Dashboard 2';; +# +# - edit the sql: parameter of filter_bindings dimension with list of filters that should be passed from one dashboard to another +# sql: 'filter1|Filter 1 Name||filter2|Filter 2 Name' ;; +# +# - edit filter1 to filterN (up to 10) to unhide and label +# +# - optional updates: +# - change item_delimiter (||) and value_delimiter (|) to match delimiters used in Bindings dimensions +# +# Once this template is extended and filter1 to filter8 are labeled, create a Single Value Visualization +# and add to a dashboard. LookML example: +# - title: navigation +# name: navigation +# explore: profit_and_loss +# type: single_value +# fields: [profit_and_loss_navigation_ext.navigation] +# filters: +# profit_and_loss_navigation_ext.navigation_focus_page: '1' +# profit_and_loss_navigation_ext.navigation_style: 'small' +# show_single_value_title: false +# show_comparison: false +# listen: +# Hierarchy: profit_and_loss_navigation_ext.filter1 +# Display Timeframe: profit_and_loss_navigation_ext.filter2 +# Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 +# Global Currency: profit_and_loss_navigation_ext.filter4 +# Company: profit_and_loss_navigation_ext.filter5 +# Ledger Name: profit_and_loss_navigation_ext.filter6 +# Top Hierarchy Level to Display: profit_and_loss_navigation_ext.filter7 +# Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 +#########################################################} + +view: navigation_template { + extension: required + ######################################## + ###### Fields *requiring override* in extension + ######################################## + + dimension: dash_bindings { + hidden: yes + type: string + sql: '131|Dashboard 1||132|Dashboard 2' ;; + } + + dimension: filter_bindings { + hidden: yes + type: string + sql: 'filter1|Filter 1 Name||filter1|Filter 2 Name' ;; + } + + # ** override hidden and label in extension as required ** + # ** Add more as required, currently supports 5 ** + filter: filter1 { hidden: yes label: "filter1"} + filter: filter2 { hidden: yes label: "filter2"} + filter: filter3 { hidden: yes label: "filter3"} + filter: filter4 { hidden: yes label: "filter4"} + filter: filter5 { hidden: yes label: "filter5"} + filter: filter6 { hidden: yes label: "filter6"} + filter: filter7 { hidden: yes label: "filter7"} + filter: filter8 { hidden: yes label: "filter8"} + filter: filter9 { hidden: yes label: "filter9"} + filter: filter10 { hidden: yes label: "filter10" } + + ######################################## + ###### Fields *optionally overriden* in extension + ######################################## + + dimension: item_delimiter { + hidden: yes + type: string + sql: '||' ;; + } + + dimension: value_delimiter { + hidden: yes + type: string + sql: '|' ;; + } + + # use parameter to choose navigation style + parameter: navigation_style { + hidden: no + type: unquoted + description: "Select navigation style (e.g., Tabs, Hyperlinks in Box or Hyperlinks with No Styling)" + allowed_value: {label: "Hyperlinks - Center Aligned in Box" value: "bar"} + allowed_value: {label: "Tabs" value: "tabs"} + allowed_value: {label: "Hyperlinks - Left Aligned - No Border - Small font" value: "small"} + default_value: "tabs" + } + + + # use parameter to set focus page until bug with _explore._dashboard_url is fixed + # update allowed values to match number of dashboards defined in extension + parameter: navigation_focus_page { + hidden: no + description: "Used in dashboard navigation to set focus on selected dashboard page" + type: unquoted + allowed_value: {value:"1"} + allowed_value: {value:"2"} + default_value: "1" + } + + ######################################## + ###### Navbar definition + ######################################## + + dimension: navigation { + type: string + hidden: no + description: "Add to Single Value Visualization. Defined HTML styling will be shown." + sql: '' ;; + html: + + {% assign navItems = dash_bindings._value | split: item_delimiter._value %} + {% assign filterItems = filter_bindings._value | split: item_delimiter._value %} + + + {% assign counter = 1 %} + {% assign navStyle = navigation_style._parameter_value %} + {% assign focus = navigation_focus_page._parameter_value | times: 1 %} + {% assign queryString = "" %} + {% assign modelName = _model._name %} + + + {% case navStyle %} + {% when "bar" %} + {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} + {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 20px;" %} + {% assign divStyle = "border-radius: 5px; padding-top: 6px; padding-bottom: 20px; height: 60px; background: #F5F5F5;" %} + {% assign spanStyle = "font-size: 18px; display: table; margin:0 auto;" %} + {% assign imgStyle = "float: left; vertical-align: middle; height: 45px;" %} + {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} + {% when "tabs" %} + {% assign sharedStyle = "font-color: #4285F4; padding: 5px 15px; border-style: solid; border-radius: 5px 5px 0 0; float: left; line-height: 20px; "%} + {% assign linkStyle = sharedStyle | append: "border-width: 1px; border-color: #D3D3D3;" %} + {% assign currentPageLinkStyle = sharedStyle | append: "border-width: 2px; border-color: #808080 #808080 #F5F5F5 #808080; font-weight: bold; background-color: #F5F5F5;" %} + {% assign divStyle = "border-bottom: solid 2px #808080; padding: 6px 10px 5px 10px; height: 40px;" %} + {% assign spanStyle = "font-size: 16px; padding: 6px 10px 0 10px; height: 40px;" %} + {% assign imgStyle = "float: left; vertical-align: middle; height: 39px;" %} + {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} + {% when "small" %} + {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} + {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 12px;" %} + {% assign divStyle = "float: left;" %} + {% assign spanStyle = "font-size: 10px; display: table; margin:0 auto;" %} + {% assign imgStyle = "" %} + {% assign imgSrc = "" %} + {% endcase %} + + + + {% for filterItem in filterItems %} + + {% assign filterParts = filterItem | split: value_delimiter._value %} + {% assign filterField = filterParts[0] %} + {% assign filterName = filterParts[1] %} + + + + + {% case filterField %} + {% when "filter1" %} + {% assign filterValue = _filters['filter1'] | url_encode %} + {% when "filter2" %} + {% assign filterValue = _filters['filter2'] | url_encode %} + {% when "filter3" %} + {% assign filterValue = _filters['filter3'] | url_encode %} + {% when "filter4" %} + {% assign filterValue = _filters['filter4'] | url_encode %} + {% when "filter5" %} + {% assign filterValue = _filters['filter5'] | url_encode %} + {% when "filter6" %} + {% assign filterValue = _filters['filter6'] | url_encode %} + {% when "filter7" %} + {% assign filterValue = _filters['filter7'] | url_encode %} + {% when "filter8" %} + {% assign filterValue = _filters['filter8'] | url_encode %} + {% when "filter9" %} + {% assign filterValue = _filters['filter9'] | url_encode %} + {% when "filter10" %} + {% assign filterValue = _filters['filter10'] | url_encode %} + {% else %} + {% assign filterValue = "out of range filter" %} + + {% endcase %} + + + {% assign filterString = filterName | append: "=" | append: filterValue %} + + + {% assign queryString = queryString | append: filterString | append: '&' %} + + {% endfor %} + + + +
+
+ + + + + {% for navItem in navItems %} + {% assign navParts = navItem | split: value_delimiter._value %} + {% assign dashName = navParts[1] %} + {% assign dashID = navParts[0] %} + {% assign dashIDcheckType = dashID | plus: 0 %} + + + + + + {% if dashIDcheckType == 0 %} + + {% if dashID contains '::' %} + {% else %} + {% assign dashID = modelName | append: '::' | append: dashID %} + {% endif %} + {% endif %} + + + {% assign dashUrl = "/dashboards/" | append: dashID %} + + + + {% if navigation_focus_page._in_query and counter == focus %} + {{ dashName }} + {% elsif _explore._dashboard_url == dashUrl %} + {{ dashName }} + {% else %} + {{ dashName }} + {% endif %} + + + {% assign counter = counter | plus: 1 %} + {% endfor %} + + +
+ + + + {% if navigation_focus_page._in_query == false %} +
+ {{ _explore._dashboard_url }} - clear cache & refresh to see active page +
+ {% endif %} +
+ + ;; + } + + +} diff --git a/views/universal_ledgers_md_base.view.lkml b/views/universal_ledgers_md_base.view.lkml new file mode 100644 index 00000000..b66e18be --- /dev/null +++ b/views/universal_ledgers_md_base.view.lkml @@ -0,0 +1,76 @@ +view: universal_ledgers_md { + sql_table_name: `@{GCP_PROJECT}.@{REPORTING_DATASET}.UniversalLedgersMD` ;; + + dimension: cash_ledger_indicator_xcash_ledger { + type: string + sql: ${TABLE}.CashLedgerIndicator_XCASH_LEDGER ;; + } + dimension: client_mandt { + type: string + sql: ${TABLE}.Client_MANDT ;; + } + dimension: corporate_accounting_principle_acc_principle { + type: string + sql: ${TABLE}.CorporateAccountingPrinciple_ACC_PRINCIPLE ;; + } + dimension: extension_ledger_type_ext_ledger_type { + type: string + sql: ${TABLE}.ExtensionLedgerType_EXT_LEDGER_TYPE ;; + } + dimension: fallback_ledger_fallback_ledger { + type: string + sql: ${TABLE}.FallbackLedger_FALLBACK_LEDGER ;; + } + dimension: language_langu { + type: string + sql: ${TABLE}.Language_LANGU ;; + } + dimension: leading_ledger_indicator_xleading { + type: string + sql: ${TABLE}.LeadingLedgerIndicator_XLEADING ;; + } + dimension: ledger_of_extension_ledger_core { + type: string + sql: ${TABLE}.LedgerOfExtensionLedger_CORE ;; + } + dimension: ledger_rldnr { + type: string + sql: ${TABLE}.Ledger_RLDNR ;; + } + dimension: ledger_type { + type: string + sql: ${TABLE}.LedgerType ;; + } + dimension: manual_postings_not_allowed_man_post_not_allwd { + type: string + sql: ${TABLE}.ManualPostingsNotAllowed_MAN_POST_NOT_ALLWD ;; + } + dimension: name_name { + type: string + sql: ${TABLE}.Name_NAME ;; + } + dimension: owner_application_appl { + type: string + sql: ${TABLE}.OwnerApplication_APPL ;; + } + dimension: sub_application_subappl { + type: string + sql: ${TABLE}.SubApplication_SUBAPPL ;; + } + dimension: technical_ledger_tech_ledger { + type: string + sql: ${TABLE}.TechnicalLedger_TECH_LEDGER ;; + } + dimension: valuation_view_subtype_valusubtyp { + type: string + sql: ${TABLE}.ValuationViewSubtype_VALUSUBTYP ;; + } + dimension: valuation_view_valutyp { + type: string + sql: ${TABLE}.ValuationView_VALUTYP ;; + } + measure: count { + type: count + drill_fields: [name_name] + } +} diff --git a/views/universal_ledgers_md_rfn.view.lkml b/views/universal_ledgers_md_rfn.view.lkml new file mode 100644 index 00000000..de97c791 --- /dev/null +++ b/views/universal_ledgers_md_rfn.view.lkml @@ -0,0 +1,38 @@ +include: "/views/universal_ledgers_md_base.view" + +view: +universal_ledgers_md { + fields_hidden_by_default: yes + + dimension: key { + type: string + primary_key: yes + sql: CONCAT(${client_mandt}, ${ledger_rldnr}, ${language_langu}) ;; + } + + dimension: ledger_rldnr { + label: "Ledger RLDNR" + } + + dimension: name_name { + hidden: no + label: "Ledger Name" + } + + dimension: ledger_id_name { + hidden: no + label: "Ledger ID - Name" + description: "Concatentation of Ledger ID and Name (e.g., 0L - Leading Ledger)" + sql: CONCAT(${ledger_rldnr},' - ',${name_name}) ;; + } + + dimension: is_leading_ledger{ + type: yesno + sql: ${leading_ledger_indicator_xleading} = 'X' ;; + } + + dimension: is_cash_ledger { + type: yesno + sql: ${cash_ledger_indicator_xcash_ledger} = 'X' ;; + } + +} From fcb2150206fc483e56e3f6b101121c42322602e3 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Tue, 19 Mar 2024 21:45:41 +0000 Subject: [PATCH 02/16] add profit and loss/income statement content for Cortex v5.4 release --- ...ent_mktplace_report_table.dashboard.lookml | 98 +++++ ...eport_table_no_comparison.dashboard.lookml | 48 +++ ..._statement_subtotal_table.dashboard.lookml | 98 +++++ ...total_table_no_comparison.dashboard.lookml | 48 +++ ...income_statement_template.dashboard.lookml | 218 ++++++++++ components/datagroups.lkml | 22 +- .../.gitkeep | 0 .../balance_sheet.explore.lkml | 0 explores_finance/profit_and_loss.explore.lkml | 58 +++ manifest.lkml | 14 + models/cortex_sap_operational.model.lkml | 2 +- ..._01_reporting_fiscal_periods_sdt.view.lkml | 104 +++++ ...02_comparison_fiscal_periods_sdt.view.lkml | 120 ++++++ ...s_03_selected_fiscal_periods_sdt.view.lkml | 384 ++++++++++++++++++ views/profit_and_loss_base.view.lkml | 123 ++++++ ...ofit_and_loss_fiscal_periods_sdt.view.lkml | 128 ++++++ ...and_loss_hierarchy_selection_sdt.view.lkml | 125 ++++++ .../profit_and_loss_navigation_ext.view.lkml | 167 ++++++++ ...profit_and_loss_path_to_node_pdt.view.lkml | 117 ++++++ views/profit_and_loss_rfn.view.lkml | 325 +++++++++++++++ 20 files changed, 2196 insertions(+), 3 deletions(-) create mode 100644 LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml create mode 100644 LookML_Dashboard/income_statement_mktplace_report_table_no_comparison.dashboard.lookml create mode 100644 LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml create mode 100644 LookML_Dashboard/income_statement_subtotal_table_no_comparison.dashboard.lookml create mode 100644 LookML_Dashboard/income_statement_template.dashboard.lookml rename {explores_balance_sheet => explores_finance}/.gitkeep (100%) rename {explores_balance_sheet => explores_finance}/balance_sheet.explore.lkml (100%) create mode 100644 explores_finance/profit_and_loss.explore.lkml create mode 100644 views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml create mode 100644 views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml create mode 100644 views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml create mode 100644 views/profit_and_loss_base.view.lkml create mode 100644 views/profit_and_loss_fiscal_periods_sdt.view.lkml create mode 100644 views/profit_and_loss_hierarchy_selection_sdt.view.lkml create mode 100644 views/profit_and_loss_navigation_ext.view.lkml create mode 100644 views/profit_and_loss_path_to_node_pdt.view.lkml create mode 100644 views/profit_and_loss_rfn.view.lkml diff --git a/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml new file mode 100644 index 00000000..39b67975 --- /dev/null +++ b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml @@ -0,0 +1,98 @@ +#########################################################{ +# Income Statement financial report using Report Table visualization (available for free on Looker Marketplace) +# EXTENDS filters and title summary from income_statement_template +# customizations: +# - Income Statement table based on marketplace_viz_report_table::report_table-marketplace +# - filter Select Comparison Type options set to yoy and prior with yoy as default +# - Navigation viz filter focus_page set to '1' and filter which_dashboard_style set to 'mktplace^_report' +#########################################################} + +- dashboard: income_statement_mktplace_report_table + title: Financial Income Statement + layout: newspaper + preferred_viewer: dashboards-next + description: "Using the Report (Table) visualization available from Looker Marketplace, this report shows a company's financial performance over a specific period (e.g., a month, quarter, or year) compared to either preceding timeframe or same timeframe last year. This report summarizes Revenues, Expenses and/or Net Income (Loss) at specified hierarchy level." + filters_location_top: false + extends: income_statement_template + + elements: + - title: income statement table + name: income statement table + explore: profit_and_loss + type: marketplace_viz_report_table::report_table-marketplace + fields: [profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text, + profit_and_loss_hierarchy_selection_sdt.hier3_node_text, profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount, + profit_and_loss_03_selected_fiscal_periods_sdt.comparison_amount, profit_and_loss_03_selected_fiscal_periods_sdt.difference_value, + profit_and_loss_03_selected_fiscal_periods_sdt.difference_percent, profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator] + pivots: [profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator] + sorts: [profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator, profit_and_loss_hierarchy_selection_sdt.hier1_node_text, + profit_and_loss_hierarchy_selection_sdt.hier2_node_text, profit_and_loss_hierarchy_selection_sdt.hier3_node_text] + show_view_names: false + theme: contemporary + layout: auto + minWidthForIndexColumns: false + headerFontSize: 12 + bodyFontSize: 12 + showTooltip: true + showHighlight: true + columnOrder: {} + rowSubtotals: true + colSubtotals: false + spanRows: true + spanCols: true + calculateOthers: true + sortColumnsBy: pivots + useViewName: false + useHeadings: false + useShortName: false + useUnit: false + groupVarianceColumns: false + genericLabelForSubtotals: false + indexColumn: false + transposeTable: false + label|profit_and_loss_hierarchy_selection_sdt.hier1_node_text: " " + label|profit_and_loss_hierarchy_selection_sdt.hier2_node_text: " " + label|profit_and_loss_hierarchy_selection_sdt.hier3_node_text: " " + subtotalDepth: '1' + style|profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount: black_red + style|profit_and_loss_03_selected_fiscal_periods_sdt.comparison_amount: black_red + style|profit_and_loss_03_selected_fiscal_periods_sdt.difference_value: black_red + style|profit_and_loss_03_selected_fiscal_periods_sdt.difference_percent: black_red + title_hidden: true + listen: + Global Currency: profit_and_loss.target_currency_tcurr + Select Fiscal Timeframe: profit_and_loss.filter_fiscal_timeframe + Display Timeframe: profit_and_loss.parameter_display_time_dimension + Select Comparison Type: profit_and_loss.parameter_compare_to + Ledger Name: universal_ledgers_md.ledger_id_name + Company: profit_and_loss.company_text + Hierarchy: profit_and_loss.glhierarchy + Top Hierarchy Level: profit_and_loss_hierarchy_selection_sdt.parameter_pick_start_level + Combine Selected Timeframes?: profit_and_loss.parameter_aggregate + row: 3 + col: 0 + width: 24 + height: 8 + + - title: navigation + name: navigation + filters: + profit_and_loss_navigation_ext.navigation_focus_page: '1' + profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'mktplace^_report' + + filters: + - name: Select Comparison Type + title: Select Comparison Type + type: field_filter + default_value: "yoy" + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + options: + - yoy + - prior + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_compare_to diff --git a/LookML_Dashboard/income_statement_mktplace_report_table_no_comparison.dashboard.lookml b/LookML_Dashboard/income_statement_mktplace_report_table_no_comparison.dashboard.lookml new file mode 100644 index 00000000..714aa0a9 --- /dev/null +++ b/LookML_Dashboard/income_statement_mktplace_report_table_no_comparison.dashboard.lookml @@ -0,0 +1,48 @@ +#########################################################{ +# Income Statement financial report using Report Table visualization (available for free on Looker Marketplace) +# but without Comparison to year ago, prior or custom fiscal periods +# EXTENDS filters and title summary from income_statement_template +# EXTENDS Income Statement Table visualization from income_statement_mktplace_report_table +# customizations: +# - filter Select Comparison Type options and default set to None +# - Removed comparison-related fields from Income Statement table from fields: property +# - Navigation viz filter focus_page set to '2' and which_dashboard_style set to 'mktplace^_report' +#########################################################} + +- dashboard: income_statement_mktplace_report_table_no_comparison + title: Financial Income Statement + layout: newspaper + preferred_viewer: dashboards-next + description: "Using the Report (Table) visualization available from Looker Marketplace, this report shows a company's financial performance over a specific period (e.g., a month, quarter, or year). This report summarizes Revenues, Expenses and/or Net Income (Loss) at specified hierarchy level." + filters_location_top: false + extends: [income_statement_template, income_statement_mktplace_report_table] + + elements: + - title: income statement table + name: income statement table + type: marketplace_viz_report_table::report_table-marketplace + fields: [profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text, + profit_and_loss_hierarchy_selection_sdt.hier3_node_text, profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator, + profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount] + + - title: navigation + name: navigation + filters: + profit_and_loss_navigation_ext.navigation_focus_page: '2' + profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'mktplace^_report' + + filters: + - name: Select Comparison Type + title: Select Comparison Type + type: field_filter + default_value: "none" + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + options: + - none + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_compare_to diff --git a/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml b/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml new file mode 100644 index 00000000..61e3eb7b --- /dev/null +++ b/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml @@ -0,0 +1,98 @@ +#########################################################{ +# Income Statement financial report using Table visualization with Subtotals +# EXTENDS filters and title summary from income_statement_template +# customizations: +# - Income Statement table based on looker_grid visualization type +# - filter Select Comparison Type options set to yoy and prior with yoy as default +# - Navigation viz filter focus_page set to '1' and filter which_dashboard_style set to 'subtotal' +#########################################################} + +- dashboard: income_statement_subtotal_table + title: Financial Income Statement + layout: newspaper + preferred_viewer: dashboards-next + description: "Shows a company's financial performance over a specific period (e.g., a month, quarter, or year) compared to either preceding timeframe or same timeframe last year. This report summarizes Revenues, Expenses and/or Net Income (Loss) at specified hierarchy level." + filters_location_top: false + extends: income_statement_template + + elements: + - title: income statement table + name: income statement table + explore: profit_and_loss + type: looker_grid + fields: [profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text, + profit_and_loss_hierarchy_selection_sdt.hier3_node_text, profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount, + profit_and_loss_03_selected_fiscal_periods_sdt.comparison_amount, profit_and_loss_03_selected_fiscal_periods_sdt.difference_value, + profit_and_loss_03_selected_fiscal_periods_sdt.difference_percent, profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator] + pivots: [profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator] + sorts: [profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator, + profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text,profit_and_loss_hierarchy_selection_sdt.hier3_node_text] + subtotals: [profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text] + limit: 500 + column_limit: 50 + total: true + show_view_names: false + show_row_numbers: false + transpose: false + truncate_text: true + hide_totals: false + hide_row_totals: false + size_to_fit: true + table_theme: white + limit_displayed_rows: false + enable_conditional_formatting: false + header_text_alignment: center + header_font_size: '12' + rows_font_size: '12' + conditional_formatting_include_totals: false + conditional_formatting_include_nulls: false + show_sql_query_menu_options: false + show_totals: true + show_row_totals: true + truncate_header: false + minimum_column_width: 75 + series_labels: + profit_and_loss_hierarchy_selection_sdt.hier1_node_text: " " + profit_and_loss_hierarchy_selection_sdt.hier2_node_text: " " + profit_and_loss_hierarchy_selection_sdt.hier3_node_text: " " + profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator: " " + series_collapsed: + profit_and_loss_hierarchy_selection_sdt.hier2_node_text: false + title_hidden: true + listen: + Global Currency: profit_and_loss.target_currency_tcurr + Select Fiscal Timeframe: profit_and_loss.filter_fiscal_timeframe + Combine Selected Timeframes?: profit_and_loss.parameter_aggregate + Display Timeframe: profit_and_loss.parameter_display_time_dimension + Select Comparison Type: profit_and_loss.parameter_compare_to + Ledger Name: universal_ledgers_md.ledger_id_name + Company: profit_and_loss.company_text + Hierarchy: profit_and_loss.glhierarchy + Top Hierarchy Level: profit_and_loss_hierarchy_selection_sdt.parameter_pick_start_level + row: 3 + col: 0 + width: 24 + height: 8 + + - title: navigation + name: navigation + filters: + profit_and_loss_navigation_ext.navigation_focus_page: '1' + profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'subtotal' + + filters: + - name: Select Comparison Type + title: Select Comparison Type + type: field_filter + default_value: "yoy" + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + options: + - yoy + - prior + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_compare_to diff --git a/LookML_Dashboard/income_statement_subtotal_table_no_comparison.dashboard.lookml b/LookML_Dashboard/income_statement_subtotal_table_no_comparison.dashboard.lookml new file mode 100644 index 00000000..00691847 --- /dev/null +++ b/LookML_Dashboard/income_statement_subtotal_table_no_comparison.dashboard.lookml @@ -0,0 +1,48 @@ +#########################################################{ +# Income Statement financial report using Table visualization with Subtotals +# EXTENDS filters and title summary from income_statement_template +# EXTENDS Income Statement Table visualization from income_statement_subtotal_table +# customizations: +# - filter Select Comparison Type options and default set to None +# - Removed comparison-related fields from Income Statement table from fields: property and set size_to_fit: property to false +# - Navigation viz filter focus_page set to '2' and filter which_dashboard_style set to 'subtotal' +#########################################################} + +- dashboard: income_statement_subtotal_table_no_comparison + title: Financial Income Statement + layout: newspaper + preferred_viewer: dashboards-next + description: "Shows a company's financial performance over a specific period (e.g., a month, quarter, or year). This report summarizes Revenues, Expenses and/or Net Income (Loss) at specified hierarchy level." + filters_location_top: false + extends: [income_statement_template, income_statement_subtotal_table] + + elements: + - title: income statement table + name: income statement table + fields: [profit_and_loss_hierarchy_selection_sdt.hier1_node_text, profit_and_loss_hierarchy_selection_sdt.hier2_node_text, + profit_and_loss_hierarchy_selection_sdt.hier3_node_text, profit_and_loss_03_selected_fiscal_periods_sdt.alignment_group_name_with_partial_indicator, + profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount] + size_to_fit: false + + + - title: navigation + name: navigation + filters: + profit_and_loss_navigation_ext.navigation_focus_page: '2' + profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'subtotal' + + filters: + - name: Select Comparison Type + title: Select Comparison Type + type: field_filter + default_value: "none" + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + options: + - none + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_compare_to diff --git a/LookML_Dashboard/income_statement_template.dashboard.lookml b/LookML_Dashboard/income_statement_template.dashboard.lookml new file mode 100644 index 00000000..13cabcf5 --- /dev/null +++ b/LookML_Dashboard/income_statement_template.dashboard.lookml @@ -0,0 +1,218 @@ +#########################################################{ +# Income Statement template which must be EXTENDED into another dashboard +# +# defines the following elements which can be shared across Income Statement-related dashboards: +# - Visualization Elements: +# Income Statement Summary visualization which appears at top of Income Statement dashboards +# footnote chart which populates if one of the selected fiscal years or quarters and it's corresponding comparison timeframe is incomplete +# else chart remains empty/blank +# navigation chart with provides two html links for With Comparisons or Without Comparisons +# +# - Filters including default values: +# Hierarchy +# Display Timeframe +# Select Fiscal Timeframe +# Combine Selected Timeframes? +# Select Comparison Type +# Global Currency +# Company +# Ledger Name +# Top Hierarchy Level +# +# The Elements and their properties can be EXTENDED into other dashboards and modified further as necessary +#########################################################} + +- dashboard: income_statement_template + title: Income Statement Template + description: "Common filters and tiles used by Income Statement dashboards" + layout: newspaper + preferred_viewer: dashboards-next + tile_size: 100 + extension: required + + elements: + - name: Income Statement Summary + title: Income Statement Summary + explore: profit_and_loss + type: single_value + fields: [profit_and_loss_03_selected_fiscal_periods_sdt.title_income_statement] + filters: + profit_and_loss.gllevel_number: '2' + profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_reporting_group: Reporting + show_single_value_title: false + listen: + Global Currency: profit_and_loss.target_currency_tcurr + Select Fiscal Timeframe: profit_and_loss.filter_fiscal_timeframe + Display Timeframe: profit_and_loss.parameter_display_time_dimension + Select Comparison Type: profit_and_loss.parameter_compare_to + Ledger Name: universal_ledgers_md.ledger_id_name + Company: profit_and_loss.company_text + Hierarchy: profit_and_loss.glhierarchy + row: 2 + col: 0 + width: 24 + height: 3 + + - name: footnote + title: footnote + explore: profit_and_loss + type: single_value + fields: [profit_and_loss_03_selected_fiscal_periods_sdt.footnote_partial_timeframe] + show_single_value_title: false + listen: + Global Currency: profit_and_loss.target_currency_tcurr + Select Fiscal Timeframe: profit_and_loss.filter_fiscal_timeframe + Display Timeframe: profit_and_loss.parameter_display_time_dimension + Select Comparison Type: profit_and_loss.parameter_compare_to + Ledger Name: universal_ledgers_md.ledger_id_name + Company: profit_and_loss.company_text + Hierarchy: profit_and_loss.glhierarchy + Combine Selected Timeframes?: profit_and_loss.parameter_aggregate + row: 10 + col: 0 + width: 24 + height: 1 + + - title: navigation + name: navigation + explore: profit_and_loss + type: single_value + fields: [profit_and_loss_navigation_ext.navigation] + filters: + profit_and_loss_navigation_ext.navigation_focus_page: '1' + profit_and_loss_navigation_ext.navigation_style: 'small' + profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'subtotal' + show_single_value_title: false + show_comparison: false + listen: + Hierarchy: profit_and_loss_navigation_ext.filter1 + Display Timeframe: profit_and_loss_navigation_ext.filter2 + Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 + Global Currency: profit_and_loss_navigation_ext.filter4 + Company: profit_and_loss_navigation_ext.filter5 + Ledger Name: profit_and_loss_navigation_ext.filter6 + Top Hierarchy Level: profit_and_loss_navigation_ext.filter7 + Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 + row: 11 + col: 0 + width: 24 + height: 1 + + + + filters: + - name: Hierarchy + title: Hierarchy + type: field_filter + default_value: FPA1 + allow_multiple_values: false + required: true + ui_config: + type: dropdown_menu + display: inline + explore: profit_and_loss + field: profit_and_loss.glhierarchy + + - name: Display Timeframe + title: Display Timeframe + type: field_filter + default_value: qtr + allow_multiple_values: false + required: false + ui_config: + type: button_toggles + display: inline + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_display_time_dimension + + - name: Select Fiscal Timeframe + title: Select Fiscal Timeframe + type: field_filter + # if using demo data default is 2023.Q4 else find current calendar quarter + default_value: "{% if _user_attributes['sap_use_demo_data']=='Yes'%}{% assign qtr = '2023.Q4'%}{%else%}{% assign q = 'now' | date: '%m' | times: 1.0 | divided_by: 3 | ceil %}{% assign qtr = 'now' | date: '%Y' | append: '.Q' | append: q %}{%endif%}{{qtr}}" + allow_multiple_values: true + required: false + ui_config: + type: tag_list + display: popover + explore: profit_and_loss + listens_to_filters: [Display Timeframe] + field: profit_and_loss.filter_fiscal_timeframe + + - name: Combine Selected Timeframes? + title: Combine Selected Timeframes? + type: field_filter + default_value: "Yes" + allow_multiple_values: false + required: false + ui_config: + type: button_toggles + display: inline + explore: profit_and_loss + field: profit_and_loss.parameter_aggregate + + - name: Select Comparison Type + title: Select Comparison Type + type: field_filter + default_value: yoy + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.parameter_compare_to + + - name: Global Currency + title: Global Currency + type: field_filter + default_value: USD + allow_multiple_values: false + required: true + ui_config: + type: dropdown_menu + display: inline + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.target_currency_tcurr + + - name: Company + title: Company + type: field_filter + default_value: "%CENTRAL%" + allow_multiple_values: false + required: false + ui_config: + type: dropdown_menu + display: inline + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss.company_text + + - name: Ledger Name + title: Ledger Name + type: field_filter + default_value: '%0L%' + allow_multiple_values: true + required: false + ui_config: + type: tag_list + display: popover + explore: profit_and_loss + listens_to_filters: [Hierarchy] + field: universal_ledgers_md.ledger_id_name + + - name: Top Hierarchy Level + title: Top Hierarchy Level + type: field_filter + default_value: '2' + allow_multiple_values: true + required: false + ui_config: + type: dropdown_menu + display: inline + explore: profit_and_loss + listens_to_filters: [] + field: profit_and_loss_hierarchy_selection_sdt.parameter_pick_start_level diff --git a/components/datagroups.lkml b/components/datagroups.lkml index 8199a27f..6d5a285e 100644 --- a/components/datagroups.lkml +++ b/components/datagroups.lkml @@ -1,6 +1,6 @@ datagroup: balance_sheet_node_count { sql_trigger: - SELECT count(0) + SELECT COUNT(0) FROM ( SELECT Client, @@ -17,6 +17,24 @@ datagroup: balance_sheet_node_count { } datagroup: monthly_on_day_1 { - sql_trigger: select extract(month from current_date) ;; + sql_trigger: select EXTRACT(MONTH from CURRENT_DATE) ;; description: "Triggers on first day of the month" } + +datagroup: profit_and_loss_node_count { + sql_trigger: + SELECT COUNT(0) + FROM ( + SELECT + Client, + ChartOfAccounts, + GLHierarchy, + GLLevel, + GLNode + FROM + `@{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss` + GROUP BY + 1, 2, 3, 4, 5) t ;; + + description: "Triggered when the Number of Distinct Client, Chart of Accounts, GLHierarchy, GLLevel and GLNodes changes" +} diff --git a/explores_balance_sheet/.gitkeep b/explores_finance/.gitkeep similarity index 100% rename from explores_balance_sheet/.gitkeep rename to explores_finance/.gitkeep diff --git a/explores_balance_sheet/balance_sheet.explore.lkml b/explores_finance/balance_sheet.explore.lkml similarity index 100% rename from explores_balance_sheet/balance_sheet.explore.lkml rename to explores_finance/balance_sheet.explore.lkml diff --git a/explores_finance/profit_and_loss.explore.lkml b/explores_finance/profit_and_loss.explore.lkml new file mode 100644 index 00000000..730c33f7 --- /dev/null +++ b/explores_finance/profit_and_loss.explore.lkml @@ -0,0 +1,58 @@ +include: "/views/profit_and_loss_rfn.view" +include: "/views/language_map_sdt.view" +include: "/views/universal_ledgers_md_rfn.view" +include: "/views/profit_and_loss_03_selected_fiscal_periods_sdt.view" +include: "/views/profit_and_loss_hierarchy_selection_sdt.view" +include: "/views/profit_and_loss_navigation_ext.view" + +explore: profit_and_loss { + always_join: [language_map_sdt] + + label: "Income Statement" + + always_filter: {filters:[profit_and_loss.glhierarchy: "",profit_and_loss.company_text: "",profit_and_loss.target_currency_tcurr: ""]} + + sql_always_where: ${profit_and_loss.client_mandt}='@{CLIENT}' + + ;; + + join: language_map_sdt { + type: inner + relationship: many_to_one + sql_on: ${profit_and_loss.language_key_spras} = ${language_map_sdt.language_spras} ;; + fields: [] + } + + join: universal_ledgers_md { + view_label: "Income Statement" + type: left_outer + relationship: many_to_one + sql_on: ${profit_and_loss.client_mandt} = ${universal_ledgers_md.client_mandt} AND + ${profit_and_loss.ledger_in_general_ledger_accounting} = ${universal_ledgers_md.ledger_rldnr} AND + ${profit_and_loss.language_key_spras} = ${universal_ledgers_md.language_langu};; + } + + join: profit_and_loss_03_selected_fiscal_periods_sdt { + type: inner + relationship: many_to_many + sql_on: ${profit_and_loss.fiscal_year} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_year} + and ${profit_and_loss.fiscal_period} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_period};; + } + + join: profit_and_loss_hierarchy_selection_sdt { + type: inner + relationship: many_to_one + sql_on: ${profit_and_loss.client_mandt} = ${profit_and_loss_hierarchy_selection_sdt.client_mandt} and + ${profit_and_loss.glhierarchy} = ${profit_and_loss_hierarchy_selection_sdt.glhierarchy} and + ${profit_and_loss.chart_of_accounts} = ${profit_and_loss_hierarchy_selection_sdt.chart_of_accounts} and + ${profit_and_loss.language_key_spras} = ${profit_and_loss_hierarchy_selection_sdt.language_key_spras} and + ${profit_and_loss.glnode} = ${profit_and_loss_hierarchy_selection_sdt.glnode} ;; + } + + join: profit_and_loss_navigation_ext { + view_label: "🔍 Filters & 🛠 Tools" + relationship: one_to_one + sql: ;; +} + +} diff --git a/manifest.lkml b/manifest.lkml index f5c519fe..d4b1d3f1 100644 --- a/manifest.lkml +++ b/manifest.lkml @@ -18,6 +18,14 @@ constant: CLIENT { export: override_required } +# Revenue is generally displayed in general ledger as a negative number, which indicates a credit. +# By setting Sign Change value to 'yes', it's displayed as a positive number in income statement reports. +constant: SIGN_CHANGE { + value: "yes" + export: override_required +} + + ############################# # Additional Constants used for formatting and other logic #{ @@ -34,5 +42,11 @@ constant: negative_format { value: "{% if value < 0 %}

{{rendered_value}}

{% else %} {{rendered_value}} {% endif %}" } +constant: sign_change_multiplier { + value: "{% assign choice = '@{SIGN_CHANGE}' | downcase %} + {% if choice == 'yes' %}{% assign multiplier = -1 %}{% else %}{% assign multiplier = 1 %}{% endif %}" +} + + #} end additional constants diff --git a/models/cortex_sap_operational.model.lkml b/models/cortex_sap_operational.model.lkml index 5c72f2fa..b9f213ec 100644 --- a/models/cortex_sap_operational.model.lkml +++ b/models/cortex_sap_operational.model.lkml @@ -4,7 +4,7 @@ connection: "@{CONNECTION_NAME}" # include all the views include: "/views/**/*.view" include: "/components/*.lkml" -include: "/explores_balance_sheet/*.explore" +include: "/explores_finance/*.explore" # Datagroups define a caching policy for an Explore. To learn more, # use the Quick Help panel on the right to see documentation. diff --git a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml new file mode 100644 index 00000000..a42a59ae --- /dev/null +++ b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml @@ -0,0 +1,104 @@ +#########################################################{ +# Step 1 of 3 in deriving Reporting and Comparison Groups of timeframes +# Step 1 - Derive Reporting selection +# This SQL Derived Table (sdt) uses view profit_and_loss_fiscal_periods_sdt as source and: +# 1) Takes user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report +# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison +# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Group else each timeframe selected will be displayed in report +# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report +# +# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters +# and filters to return the "Reporting" timeframe selected +# +# 3) Derives new dimensions: +# fiscal_reporting_group -- value of Reporting +# alignment_group -- if parameter_aggregate = 'Yes' assign 1 else +# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. If multiple timeframes selected, each set of comparisons will be given a unique group number +# +# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: +# alignment group 1 = 2024.001 compared to 2023.001 +# alignment group 2 = 2024.002 compared to 2023.002 +# +# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: +# alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 +# +# selected_timeframe -- returns either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension +# timeframe_join -- added if parameter_compare_to != 'none'; used in Step 2 to join between reporting and profit_and_loss_fiscal_periods_sdt to derive comparison periods +# -- if parameter_compare_to = 'yoy' then fiscal_year_period +# else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then use the [timeframe]_rank for the selected timeframe +# else if parameter_compare_to = 'prior' and parameter_aggregate = 'No' then use the selected timeframe field (fiscal_year_period, fiscal_year_quarter or fiscal_year) +# +# prior_timeframe_join -- added if parameter_compare_to != 'none'; used in Step 2 to join between reporting and profit_and_loss_fiscal_periods_sdt to derive comparison periods +# -- if parameter_compare_to = 'yoy' then yoy_fiscal_year_period +# -- else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then derive as: +# [timeframe]_rank + ( +# max([timeframe]_rank) over (partition by glhierarchy, company_code) - +# min([timeframe]_rank) over (partition by glhierarchy, company_code) ) + 1 +# -- else if paramter_compare_to = 'prior' and parameter_aggregate = 'No' then derive as: +# prior_[timeframe] +#########################################################} + +include: "/views/profit_and_loss_fiscal_periods_sdt.view" + +view: profit_and_loss_01_reporting_fiscal_periods_sdt { + extends: [profit_and_loss_fiscal_periods_sdt] + + fields_hidden_by_default: no + + derived_table: { + sql: + {% assign comparison_type = profit_and_loss.parameter_compare_to._parameter_value %} + {% assign time_level = profit_and_loss.parameter_display_time_dimension._parameter_value %} + {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} + {% assign window_partition = "(PARTITION BY glhierarchy, company_code)" %} + {% if time_level == 'fp' %}{% assign timeframe_field = "fiscal_year_period" %}{% assign is_partial_sql = "false" %} + {% elsif time_level == 'qtr' %}{% assign timeframe_field = "fiscal_year_quarter" %} + {% assign is_partial_sql = "is_qtd" %} + {% elsif time_level == 'yr' %}{% assign timeframe_field = "fiscal_year" %}{% assign is_partial_sql = "is_ytd" %} + {% else %}{% assign is_partial_sql = "" %} + {% endif %} + {% assign rank_field = timeframe_field | append: "_rank" %} + + {% if comparison_type == 'yoy' %} + {% assign timeframe_join_sql = "fiscal_year_period" %} + {% assign prior_timeframe_join_sql = "yoy_fiscal_year_period" %} + {% elsif comparison_type == 'prior' and aggregate == 'Yes' %} + {% assign timeframe_join_sql = timeframe_field | append: "_rank" %} + {% assign prior_timeframe_join_sql = rank_field | append: " + (max(" | append: rank_field | append: ") over (window_pk) - min(" | append: rank_field | append: ") over (window_pk) + 1 )" %} + {% elsif comparison_type == 'prior' and aggregate == 'No' %} + {% assign timeframe_join_sql = timeframe_field %} + {% assign prior_timeframe_join_sql = "prior_" | append: timeframe_field %} + {% endif %} + + {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} + {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (window_pk ORDER BY " | append: timeframe_field | append: " DESC)" %} + {% endif %} + + + + SELECT glhierarchy, + company_code, + fiscal_year, + fiscal_period, + fiscal_quarter, + fiscal_year_quarter, + fiscal_year_period, + period_order_in_quarter, + {{alignment_group_sql}} AS alignment_group, + {{timeframe_field}} AS selected_timeframe, + {% if comparison_type != "none" %} + {{timeframe_join_sql}} as timeframe_join, + {{prior_timeframe_join_sql}} as prior_timeframe_join, + {% endif %} + {{is_partial_sql}} as is_partial_timeframe, + 'Reporting' AS fiscal_reporting_group + FROM ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} fp + WHERE {% condition profit_and_loss.filter_fiscal_timeframe %}{{timeframe_field}}{% endcondition %} + WINDOW window_pk AS {{window_partition}} + ;; + } + +} diff --git a/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml new file mode 100644 index 00000000..e3b1656d --- /dev/null +++ b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml @@ -0,0 +1,120 @@ +#########################################################{ +# Step 2 of 3 in deriving Reporting and Comparison Groups of fiscal periods +# Step 2 - Derive Comparison periods based on Reporting selection +# This SQL Derived Table (sdt) uses these views: +# profit_and_loss_fiscal_periods_sdt (aliased below as comp) +# profit_and_loss_01_reporting_fiscal_periods_sdt (aliased below as rep) +# +# Purpose: +# 1) Takes user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report +# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison +# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Period else each timeframe selected will be displayed in report +# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report +# +# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters +# and filters to return the "Comparison" timeframes +# +# Uses a JOIN between profit_and_loss_01_reporting_fiscal_periods_sdt and profit_and_loss_fiscal_periods_sdt to derive the comparison period +# using either yoy or prior fiscal year/fiscal year quarter/fiscal year period +# For example, if user selects to display Fiscal Period and compare to last year, +# the derived join statement will be: +# FROM profit_and_loss_01_reporting_fiscal_periods_sdt rep +# JOIN profit_and_loss_fiscal_periods_sdt comp +# ON rep.glhierarchy = comp.glhierarchy +# AND rep.company_code = comp.company_code +# AND rep.yoy_fiscal_year_period = comp.fiscal_year_period +# +# Another example, if user selects to display Fiscal Quarter, compare to Prior Quarter, and Aggregate results +# the derived join statement will be: +# FROM profit_and_loss_01_reporting_fiscal_periods_sdt rep +# JOIN profit_and_loss_fiscal_periods_sdt comp +# ON rep.glhierarchy = comp.glhierarchy +# AND rep.company_code = comp.company_code +# AND rep.prior_fiscal_quater_rank = comp.fiscal_year_quarter_rank +# AND rep.period_order_in_quarter = comp.period_order_in_quarter +# +# NOTE, If the user selects a partial year or quarter, the comparison period will also be a partial year or quarter +# +# 3) Derives new dimensions: +# fiscal_reporting_group -- value of Comparison +# alignment_group -- if parameter_aggregate = 'Yes' assign 1 else +# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. If multiple timeframes selected, each set of comparisons will be given a unique group number +# +# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: +# alignment group 1 = 2024.001 compared to 2023.001 +# alignment group 2 = 2024.002 compared to 2023.002 +# +# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: +# alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 +# +# selected_timeframe -- returns either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension +#########################################################} + +include: "/views/profit_and_loss_fiscal_periods_sdt.view" +include: "/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view" + + +view: profit_and_loss_02_comparison_fiscal_periods_sdt { + extends: [profit_and_loss_fiscal_periods_sdt] + derived_table: { + sql: + {% assign comparison_type = profit_and_loss.parameter_compare_to._parameter_value %} + + {% if comparison_type != "none" %} + {% assign time_level = profit_and_loss.parameter_display_time_dimension._parameter_value %} + {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} + {% assign window_partition = "(PARTITION BY comp.glhierarchy, comp.company_code)" %} + {% if time_level == 'fp' %} + {% assign timeframe_field = "fiscal_year_period" %} + {% assign join2_sql = "" %} + {% elsif time_level == 'qtr' %} + {% assign timeframe_field = "fiscal_year_quarter" %} + {% assign join2_sql = "AND rep.period_order_in_quarter = comp.period_order_in_quarter" %} + {% elsif time_level == 'yr' %} + {% assign timeframe_field = "fiscal_year" %} + {% assign join2_sql = "AND rep.fiscal_period = comp.fiscal_period" %} + {% endif %} + {% assign rank_field = timeframe_field | append: "_rank" %} + + {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} + {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (window_pk ORDER BY comp." | append: timeframe_field | append: " DESC)" %} + {% endif %} + + {% if comparison_type == 'yoy' %}{% assign timeframe_join_sql = "fiscal_year_period" %} + {% elsif comparison_type == 'prior' and aggregate == 'Yes' %}{% assign timeframe_join_sql = timeframe_field | append: "_rank" %} + {% elsif comparison_type == 'prior' and aggregate == 'No' %}{% assign timeframe_join_sql = timeframe_field %} + {% else %}{% assign timeframe_join_sql = "" %} + {% endif %} + + {% assign join1_sql = "AND rep.prior_timeframe_join = comp." | append: timeframe_join_sql %} + + + SELECT comp.glhierarchy, + comp.company_code, + comp.fiscal_year_period, + comp.fiscal_year_quarter, + comp.fiscal_year, + comp.fiscal_period, + {{alignment_group_sql}} AS alignment_group, + comp.{{timeframe_field}} AS selected_timeframe, + rep.is_partial_timeframe, + 'Comparison' AS fiscal_reporting_group + FROM ${profit_and_loss_01_reporting_fiscal_periods_sdt.SQL_TABLE_NAME} rep + JOIN ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} comp + ON rep.glhierarchy = comp.glhierarchy + AND rep.company_code = comp.company_code + {{join1_sql}} + {{join2_sql}} + WINDOW window_pk AS {{window_partition}} + + {% else %} + SELECT 1 as dummy_field + {% endif %} + ;; + + } + +} diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml new file mode 100644 index 00000000..e3b8d2fb --- /dev/null +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -0,0 +1,384 @@ +#########################################################{ +# Step 3 of 3 in deriving Reporting and Comparison Groups +# Step 3 - Combine Reporting and Comparison Groups +# This SQL Derived Table (sdt) uses these views: +# profit_and_loss_01_reporting_fiscal_periods_sdt (aliased below as rep) +# profit_and_loss_02_comparison_fiscal_periods_sdt (aliased below as comp) +# +# Keys to using this view: +# - View label is "Reporting vs. Comparison Period" +# - Fields are hidden by default so must change hidden: property to no to include in an explore +# - includes references to fields from view profit_and_loss so always join this view to profit_and_loss using an inner join on: +# glhierarchy, company_code, fiscal_year, fiscal_period +# Note, the profit_and_loss_fiscal_periods_sdt view already filters to the same Client id so it is not needed in the join. +# +# Purpose: +# 1) Takes user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report +# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison +# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Period else each timeframe selected will be displayed in report +# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report +# +# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters +# and combines "Reporting" and "Comparison" rows using UNION ALL +# +# 3) Derives new dimensions: +# alignment_group_name -- if parameter_aggregate = 'Yes' assign list of timeframes selected else +# derive with MAX([timeframe]) OVER (glhierarchy, company_code, alignment_group) +# +# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: +# alignment group 1 = 2024.001 compared to 2023.001 and alignment_group_name = 2024.001 +# alignment group 2 = 2024.002 compared to 2023.002 and alignment_group_name = 2024.002 +# +# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: +# alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 +# and alignment_group_name = 2024.001, 2024.002 +# +# reporting_timeframes_list -- captures the values selected in filter_fiscal_timeframe as a string (e.g., 2024.001, 2024.002, 2024.003) +# is_partial_timeframe -- Value of true if selected_timeframe (fiscal_year/fiscal_year_quarter) is incomplete else false. Note does not check if fiscal_year_period is incomplete +# is_partial_timeframe_in_alignment_group -- If any of the timeframes in the alignment_group are incomplete then true else false +# +# 4) Defines reporting measures: +# reporting_amount +# comparison_amount +# difference_value +# difference_percent +# +##########################################################} + +include: "/views/profit_and_loss_0*.view" + +view: profit_and_loss_03_selected_fiscal_periods_sdt { + label: "Reporting vs. Comparison Period" + fields_hidden_by_default: yes + + derived_table: { + sql: + {% assign comparison_type = profit_and_loss.parameter_compare_to._parameter_value %} + {% assign time_level = profit_and_loss.parameter_display_time_dimension._parameter_value | slice: 0 %} + {% assign tp_list = _filters['profit_and_loss.filter_fiscal_timeframe'] | sql_quote | remove: '"' | remove: "'" | replace: ",",", " | split: ", " %} + {% assign tp_list = tp_list | sort | join: ", " %} + {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} + {% assign window_alignment = "(PARTITION BY glhierarchy, company_code, alignment_group)" %} + {% if time_level == "f" %}{% assign time_level_sql = "Fiscal Year Period"%}{%elsif time_level == "q"%}{% assign time_level_sql = "Fiscal Quarter"%}{%elsif time_level == "y" %}{% assign time_level_sql = "Fiscal Year"%}{% else %}{% assign time_level_sql = "None"%}{%endif%} + {% if aggregate == 'Yes' %}{% assign alignment_group_name_sql = "'" | append: tp_list | append: "'" %} + {% else %}{% assign alignment_group_name_sql = "MAX(selected_timeframe) OVER (window_alignment)" %} + {% endif %} + {% if profit_and_loss.filter_fiscal_timeframe._is_filtered %} + SELECT glhierarchy, + company_code, + fiscal_year, + fiscal_period, + fiscal_year_quarter, + fiscal_year_period, + fiscal_reporting_group, + alignment_group, + {{alignment_group_name_sql}} AS alignment_group_name, + selected_timeframe, + is_partial_timeframe, + '{{time_level_sql}}' as selected_time_level, + MAX(is_partial_timeframe) OVER (window_alignment) AS is_partial_timeframe_in_alignment_group, + MAX(fiscal_year_period) OVER (PARTITION BY glhierarchy, company_code, selected_timeframe) AS max_fiscal_year_period_selected_timeframe, + '{{tp_list}}' as reporting_timeframes_list + FROM ( + SELECT + glhierarchy, + company_code, + fiscal_year, + fiscal_period, + fiscal_year_quarter, + fiscal_year_period, + fiscal_reporting_group, + alignment_group, + selected_timeframe, + is_partial_timeframe + FROM ${profit_and_loss_01_reporting_fiscal_periods_sdt.SQL_TABLE_NAME} cur + {% if comparison_type != 'none' %} + UNION ALL + SELECT + glhierarchy, + company_code, + fiscal_year, + fiscal_period, + fiscal_year_quarter, + fiscal_year_period, + fiscal_reporting_group, + alignment_group, + selected_timeframe, + is_partial_timeframe + FROM ${profit_and_loss_02_comparison_fiscal_periods_sdt.SQL_TABLE_NAME} comp + {% endif %} + ) combine + WINDOW window_alignment AS {{window_alignment}} + {% else %} + SELECT + CAST(NULL AS STRING) AS glhierarchy, + CAST(NULL AS STRING) AS company_code, + CAST(NULL AS STRING) AS fiscal_year, + CAST(NULL AS STRING) AS fiscal_period, + CAST(NULL AS STRING) AS fiscal_year_quarter, + CAST(NULL AS STRING) AS fiscal_year_period, + CAST(NULL AS STRING) AS fiscal_reporting_group, + CAST(NULL AS STRING) AS alignment_group, + CAST(NULL AS STRING) AS alignment_group_name, + CAST(NULL AS STRING) AS selected_timeframe, + CAST(NULL AS BOOLEAN) AS is_partial_timeframe, + CAST(NULL AS BOOLEAN) AS is_partial_timeframe_in_alignment_group, + CAST(NULL AS STRING) AS reporting_timeframes_list + {% endif %} + ;; + } + + dimension: key { + type: string + hidden: yes + primary_key: yes + sql: CONCAT(${glhierarchy},${company_code},${fiscal_reporting_group},${fiscal_year},${fiscal_period}) ;; + } + + dimension: glhierarchy { + type: string + sql: ${TABLE}.glhierarchy ;; + } + + dimension: company_code { + type: string + sql: ${TABLE}.company_code ;; + } + + dimension: fiscal_year { + type: string + sql: ${TABLE}.fiscal_year ;; + } + + dimension: fiscal_period { + type: string + sql: ${TABLE}.fiscal_period ;; + } + + dimension: fiscal_year_period { + type: string + sql: ${TABLE}.fiscal_year_period ;; + } + + dimension: selected_timeframe { + type: string + hidden: no + description: "Returns value reflecting either Fiscal Year, Fiscal Year Quarter or Fiscal Year Period as defined by parameter Display Year, Quarter or Period." + sql: ${TABLE}.selected_timeframe;; + } + + dimension: selected_time_level { + type: string + hidden: no + description: "Returns selected value of parameter Display Year, Quarter or Period." + sql: ${TABLE}.selected_time_level;; + } + + dimension: max_fiscal_year_period_selected_timeframe { + sql: ${TABLE}.max_fiscal_year_period_selected_timeframe ;; + } + + dimension: reporting_timeframes_list { + type: string + hidden: no + description: "List of fiscal timeframes selected by user with filter Select Fiscal Timeframes. Example lists include 2024.001, 2024.002 or 2023.Q3, 2023.Q4, 2024.Q1" + sql: ${TABLE}.reporting_timeframes_list ;; + } + + dimension: reporting_timeframes_list_with_partial_indicator { + type: string + hidden: yes + description: "List of fiscal timeframes selected by user with filter Select Fiscal Timeframes. Example lists include 2024.001, 2024.002 or 2023.Q3, 2023.Q4, 2024.Q1. An '*' is appended to end if one of the timeframes is incomplete." + sql: CASE WHEN ${is_partial_timeframe_in_alignment_group} THEN CONCAT(${TABLE}.reporting_timeframes_list,'*') ELSE ${TABLE}.reporting_timeframes_list END ;; + } + + dimension: fiscal_reporting_group { + type: string + hidden: no + description: "Identifies the Reporting or Comparison reporting group. In fiscal reporting, the Reporting group is determined by the values selected in the Select Fiscal Timeframes filter, while the Comparison group is defined by the Compare To parameter, which can be set to either Year Ago or Prior Timeframe." + sql: ${TABLE}.fiscal_reporting_group;; + } + + dimension: alignment_group { + type: number + hidden: yes + sql: ${TABLE}.alignment_group ;; + } + + dimension: alignment_group_name { + type: string + hidden: no + description: "Name for Grouped Timeframes Included in the same Reporting vs. Comparison set. For example, if Period 2024.001 is to be compared to a Year Ago, the periods 2024.001 and 2023.001 are assigned to same alignment group and given the label 2024.001." + sql: ${TABLE}.alignment_group_name ;; + order_by_field: alignment_group + } + + dimension: alignment_group_name_with_partial_indicator { + type: string + hidden: no + description: "Name for Grouped Timeframes Included in the same Reporting vs. Comparison set. For example, if Period 2024.001 is to be compared to a Year Ago, the periods 2024.001 and 2023.001 are assigned to same alignment group and given the label 2024.001. If a partial Year or Quarter is selected, then an '*' is appended to name" + # sql: ${TABLE}.alignment_group_name ;; + sql: CASE WHEN ${is_partial_timeframe_in_alignment_group} THEN CONCAT(${TABLE}.alignment_group_name,'*') ELSE ${TABLE}.alignment_group_name END ;; + order_by_field: alignment_group + } + + dimension: is_partial_timeframe { + type: yesno + hidden: no + description: "Selected timeframe of either Fiscal Year or Fiscal Quarter is incomplete. Note, Fiscal Period is not flagged as incomplete." + sql: ${TABLE}.is_partial_timeframe ;; + } + + dimension: is_partial_timeframe_in_alignment_group { + type: yesno + hidden: no + description: "At least one timeframe in the Alignment Group is incomplete. Note, Fiscal Period is not flagged as incomplete." + sql: ${TABLE}.is_partial_timeframe_in_alignment_group ;; + } + + dimension: selected_timeframe_label { + type: string + hidden: yes + description: "If the timeframe reflects a partial period then an '*' is appended to the timeframe description." + group_label: "Reporting vs. Comparison Period" + sql: CASE WHEN ${is_partial_timeframe} THEN CONCAT(${selected_timeframe},"*") ELSE ${selected_timeframe} END ;; + } + + dimension: selected_timeframe_comparison { + type: string + hidden: yes + sql: case when ${fiscal_reporting_group} = "Comparison" then ${selected_timeframe_label} end ;; + } + + dimension: selected_timeframe_reporting { + type: string + hidden: yes + sql: case when ${fiscal_reporting_group} = "Reporting" then ${selected_timeframe_label} end ;; + } + + dimension: fiscal_year_period_comparison { + type: string + hidden: yes + sql: case when ${fiscal_reporting_group} = "Comparison" then ${fiscal_year_period} end ;; + } + + dimension: fiscal_year_period_reporting { + type: string + hidden: yes + sql: case when ${fiscal_reporting_group} = "Reporting" then ${fiscal_year_period} end ;; + } + + measure: reporting_amount { + type: sum_distinct + hidden: no + # Label is Reporting Amount by default. If filter_fiscal_timeframe in query and parameter_compare_to = 'none' then leave label blank" + label: "{% assign compare = profit_and_loss.parameter_compare_to._parameter_value %}{% if profit_and_loss.filter_fiscal_timeframe._in_query and compare == 'none'%} {% else %}Reporting Amount{% endif %}" + description: "Amount in Global Currency for the Reporting fiscal reporting group." + sql_distinct_key: ${profit_and_loss.key} ;; + sql: ${profit_and_loss.amount_in_target_currency} ;; + filters: [fiscal_reporting_group: "Reporting"] + value_format_name: decimal_0 + html: @{negative_format} ;; + } + + measure: comparison_amount { + type: sum_distinct + hidden: no + # Label is Comparison Amount by default. If filter_fiscal_timeframe in query, then Label is Year Ago Amount, Prior Amount or None based on parameter_compare_to + label: "{% if profit_and_loss.filter_fiscal_timeframe._in_query%}{% assign compare = profit_and_loss.parameter_compare_to._parameter_value %}{% if compare == 'yoy' %}{%assign compare_label = 'Year Ago Amount' %}{%elsif compare == 'prior'%}{%assign compare_label = 'Prior Amount'%}{% else %}{% assign compare_label = 'None' %}{%endif%}{{compare_label}}{%else%}Comparison Amount{%endif%}" + description: "Amount in Global Currency for the Comparison fiscal reporting group." + sql_distinct_key: ${profit_and_loss.key} ;; + sql: {% if profit_and_loss.parameter_compare_to._parameter_value != 'none' %}${profit_and_loss.amount_in_target_currency}{%else%}NULL{%endif%} ;; + filters: [fiscal_reporting_group: "Comparison"] + value_format_name: decimal_0 + html: {% if profit_and_loss.parameter_compare_to._parameter_value != 'none' %}@{negative_format}{%else%} {%endif%} ;; + } + + measure: difference_value { + type: number + hidden: no + label: "Variance Amount" + description: "Reporting Amount - Comparison Amount" + sql: {% if profit_and_loss.parameter_compare_to._parameter_value != 'none' %}${reporting_amount} - ${comparison_amount}{%else%}NULL{%endif%} ;; + value_format_name: decimal_0 + html: {% if profit_and_loss.parameter_compare_to._parameter_value != 'none' %}@{negative_format}{%else%} {%endif%} ;; + } + + measure: difference_percent { + type: number + hidden: no + label: "Variance %" + description: "Percent difference between Reporting Amount and Comparison Amount." + sql: SAFE_DIVIDE( (${reporting_amount} - ${comparison_amount}),ABS(${comparison_amount})) ;; + value_format_name: percent_1 + html: {% if profit_and_loss.parameter_compare_to._parameter_value != 'none' %}@{negative_format}{%else%} {%endif%} ;; + } + + measure: any_timeframe_is_partial { + type: yesno + hidden: yes + sql: MAX(${is_partial_timeframe});; + } + + measure: max_partial_timeframe_reporting { + type: string + sql: MAX(CASE WHEN ${fiscal_reporting_group} = 'Reporting' AND ${is_partial_timeframe} THEN ${selected_timeframe} END) ;; + } + + measure: max_partial_timeframe_comparison { + type: string + sql: MAX(CASE WHEN ${fiscal_reporting_group} = 'Comparison' AND ${is_partial_timeframe} THEN ${selected_timeframe} END) ;; + } + + measure: max_fiscal_period_in_partial_timeframe_reporting { + type: string + sql: MAX(CASE WHEN ${fiscal_reporting_group} = 'Reporting' AND ${is_partial_timeframe} THEN ${fiscal_period} END) ;; + } + + measure: max_fiscal_period_in_partial_timeframe_comparison { + type: string + sql: MAX(CASE WHEN ${fiscal_reporting_group} = 'Comparison' THEN ${fiscal_period} END) ;; + } + +# used in Income Statement dashboard; add to a single-value visualization + measure: title_income_statement { + type: number + description: "Add this measure to a single-value visualization. Returns a Summary visualization with Company, Global Currency, Reporting Fiscal Timeframes and Total Net Income." + hidden: no + sql: 1 ;; + html: +
+ Income Statement
+ {{profit_and_loss.company_text._value}}
+ Reporting Fiscal Timeframe: {{reporting_timeframes_list_with_partial_indicator._value}}    Net Income: {{profit_and_loss.net_income._rendered_value}}M +
+ Amounts in {{profit_and_loss.target_currency_tcurr}} +
+ ;; + } + +# used in Income Statement dashboard; add to a single-value visualization + measure: footnote_partial_timeframe { + type: string + hidden: no + description: "Add this measure to a single-value visualization. Returns a footnote indicating if a partial timeframe is included in the report and if so, it's max fiscal period. Should be added to a single value visualization." + sql: MAX('1') ;; + html: {% if any_timeframe_is_partial._value == 'Yes' %}{% assign time_level = selected_time_level._value %}{% assign compare_to = profit_and_loss.parameter_compare_to._parameter_value %} + {% assign note = '*' | append: time_level | append: ' To Date:' %}{% assign reporting_time = max_partial_timeframe_reporting._value %}{% assign reporting_max = ' through period ' | append: max_fiscal_period_in_partial_timeframe_reporting._value %} + {% assign compare_max = ' through period ' | append: max_fiscal_period_in_partial_timeframe_comparison._value %} + {% assign reporting_note = ' Reporting ' | append: reporting_time %} + {% if compare_to == 'none' %}{% assign comparison_note = reporting_max %} + {% elsif compare_to == 'yoy' or time_level == 'Fiscal Year' %}{% assign comparison_note = ' & Year Ago comparison through period ' | append: reporting_max %} + {% elsif compare_to == 'prior' and time_level != 'Fiscal Year' %}{% assign comparison_note = reporting_max | append: ' & Comparison ' | append: max_partial_timeframe_comparison._value | append: ' through period ' | append: compare_max %} + {% else %}{% assign comparison_note = ' '%} + {% endif %} +
+ {{note}}{{reporting_note}}{{comparison_note}}
+ {% else %} {%endif%} + ;; + } + +} diff --git a/views/profit_and_loss_base.view.lkml b/views/profit_and_loss_base.view.lkml new file mode 100644 index 00000000..5d34cbd1 --- /dev/null +++ b/views/profit_and_loss_base.view.lkml @@ -0,0 +1,123 @@ +view: profit_and_loss { + sql_table_name: `@{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss` ;; + + dimension: amount_in_local_currency { + type: number + sql: ${TABLE}.AmountInLocalCurrency ;; + } + dimension: amount_in_target_currency { + type: number + sql: ${TABLE}.AmountInTargetCurrency ;; + } + dimension: avg_exchange_rate { + type: number + sql: ${TABLE}.AvgExchangeRate ;; + } + dimension: business_area { + type: string + sql: ${TABLE}.BusinessArea ;; + } + dimension: chart_of_accounts { + type: string + sql: ${TABLE}.ChartOfAccounts ;; + } + dimension: client { + type: string + sql: ${TABLE}.Client ;; + } + dimension: company_code { + type: string + sql: ${TABLE}.CompanyCode ;; + } + dimension: company_text { + type: string + sql: ${TABLE}.CompanyText ;; + } + dimension: cost_center { + type: string + sql: ${TABLE}.CostCenter ;; + } + dimension: cumulative_amount_in_local_currency { + type: number + sql: ${TABLE}.CumulativeAmountInLocalCurrency ;; + } + dimension: cumulative_amount_in_target_currency { + type: number + sql: ${TABLE}.CumulativeAmountInTargetCurrency ;; + } + dimension: currency_key { + type: string + sql: ${TABLE}.CurrencyKey ;; + } + dimension: exchange_rate { + type: number + sql: ${TABLE}.ExchangeRate ;; + } + dimension: fiscal_period { + type: string + sql: ${TABLE}.FiscalPeriod ;; + } + dimension: fiscal_quarter { + type: number + sql: ${TABLE}.FiscalQuarter ;; + } + dimension: fiscal_year { + type: string + sql: ${TABLE}.FiscalYear ;; + } + dimension: glfinancial_item { + type: string + sql: ${TABLE}.GLFinancialItem ;; + } + dimension: glhierarchy { + type: string + sql: ${TABLE}.GLHierarchy ;; + } + dimension: glis_leaf_node { + type: yesno + sql: ${TABLE}.GLIsLeafNode ;; + } + dimension: gllevel { + type: string + sql: ${TABLE}.GLLevel ;; + } + dimension: glnode { + type: string + sql: ${TABLE}.GLNode ;; + } + dimension: glnode_text { + type: string + sql: ${TABLE}.GLNodeText ;; + } + dimension: glparent { + type: string + sql: ${TABLE}.GLParent ;; + } + dimension: glparent_text { + type: string + sql: ${TABLE}.GLParentText ;; + } + dimension: language_key_spras { + type: string + sql: ${TABLE}.LanguageKey_SPRAS ;; + } + dimension: ledger_in_general_ledger_accounting { + type: string + sql: ${TABLE}.LedgerInGeneralLedgerAccounting ;; + } + dimension: max_exchange_rate { + type: number + sql: ${TABLE}.MaxExchangeRate ;; + } + dimension: profit_center { + type: string + sql: ${TABLE}.ProfitCenter ;; + } + dimension: target_currency_tcurr { + type: string + sql: ${TABLE}.TargetCurrency_TCURR ;; + } + measure: count { + type: count + } +} diff --git a/views/profit_and_loss_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_fiscal_periods_sdt.view.lkml new file mode 100644 index 00000000..88de878d --- /dev/null +++ b/views/profit_and_loss_fiscal_periods_sdt.view.lkml @@ -0,0 +1,128 @@ +#########################################################{ +# Finds the Fiscal Years and Periods available in Profit and Loss +# and derives: +# prior dimension for fiscal year, quarter and period +# year ago fiscal period +# max fiscal period in a fiscal year (used to identify YTD selections) +# max periods in a quarter (used for identify QTD selections) +# +# Used as source for finding Current and Comparison Periods based on user selection +#########################################################} + +view: profit_and_loss_fiscal_periods_sdt { + derived_table: { + sql: + SELECT + CONCAT(glhierarchy,company_code,fiscal_year,fiscal_period) as unique_id, + glhierarchy, + company_code, + fiscal_year, + fiscal_quarter, + fiscal_period, + CONCAT(fiscal_year,'.Q',fiscal_quarter) AS fiscal_year_quarter, + CONCAT(fiscal_year,'.',fiscal_period) as fiscal_year_period, + rank() over (partition by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_period) desc) as fiscal_year_period_rank, + dense_rank() over (partition by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_quarter) desc) as fiscal_year_quarter_rank, + dense_rank() over (partition by glhierarchy, company_code order by fiscal_year desc) as fiscal_year_rank, + --prior fiscal year, quarter and period + CAST(PARSE_NUMERIC(fiscal_year) - 1 AS STRING) as prior_fiscal_year, + LAG(CONCAT(fiscal_year,'.Q',fiscal_quarter),3) OVER (PARTITION BY glhierarchy, company_code ORDER BY fiscal_year, fiscal_quarter) as prior_fiscal_year_quarter, + LAG(CONCAT(fiscal_year,'.',fiscal_period)) OVER (PARTITION BY glhierarchy, company_code ORDER BY fiscal_year, fiscal_period) as prior_fiscal_year_period, + --yoy period + CONCAT(PARSE_NUMERIC(fiscal_year) - 1,'.',fiscal_period) as yoy_fiscal_year_period, + --derive max fiscal period for year, max number of periods in quarter and period order in quarter (will be used to identify partial/incomplete time periods) + MAX(fiscal_period) OVER (PARTITION BY glhierarchy, company_code) as max_fiscal_period_in_year, + COUNT (DISTINCT fiscal_period) OVER (PARTITION BY glhierarchy, company_code, fiscal_quarter) as max_periods_in_quarter, + COUNT (DISTINCT fiscal_period) OVER (PARTITION BY glhierarchy, company_code, fiscal_quarter) > COUNT (DISTINCT fiscal_period) OVER (PARTITION BY glhierarchy, company_code, fiscal_year, fiscal_quarter) as is_qtd, + MAX(fiscal_period) OVER (PARTITION BY glhierarchy, company_code) > MAX(fiscal_period) OVER (PARTITION BY glhierarchy, company_code, fiscal_year) as is_ytd, + RANK() OVER (PARTITION BY glhierarchy, company_code, fiscal_year, fiscal_quarter ORDER by fiscal_period) as period_order_in_quarter + FROM ( + SELECT + GLHierarchy as glhierarchy, + CompanyCode as company_code, + FiscalYear as fiscal_year, + FiscalQuarter as fiscal_quarter, + FiscalPeriod as fiscal_period + FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss` AS pl + WHERE Client = '@{CLIENT}' + GROUP BY + glhierarchy, + company_code, + fiscal_year, + fiscal_quarter, + fiscal_period + + ) p + ;; + } + + dimension: unique_id { + type: string + primary_key: yes + sql: ${TABLE}.unique_id ;; + } + + dimension: glhierarchy { + type: string + sql: ${TABLE}.glhierarchy ;; + } + + dimension: company_code { + type: string + sql: ${TABLE}.company_code ;; + } + + dimension: fiscal_year { + type: string + sql: ${TABLE}.fiscal_year ;; + } + + dimension: fiscal_quarter { + type: string + sql: ${TABLE}.fiscal_quarter ;; + } + + dimension: fiscal_period { + type: string + sql: ${TABLE}.fiscal_period ;; + } + + dimension: fiscal_year_quarter { + type: string + sql: ${TABLE}.fiscal_year_quarter ;; + } + + dimension: fiscal_year_period { + type: string + sql: ${TABLE}.fiscal_year_period ;; + # order_by_field: negative_fiscal_year_period_number + } + + dimension: fiscal_year_period_number { + type: number + sql: PARSE_NUMERIC(${fiscal_year_period}) ;; + # order_by_field: negative_fiscal_year_period_number + } + + dimension: prior_fiscal_year { + type: string + sql: ${TABLE}.prior_fiscal_year ;; + } + + dimension: prior_fiscal_year_quarter { + type: string + sql: ${TABLE}.prior_fiscal_year_quarter ;; + } + + dimension: prior_fiscal_year_period { + type: string + sql: ${TABLE}.prior_fiscal_year_period ;; + } + + dimension: yoy_fiscal_year_period { + type: string + sql: ${TABLE}.yoy_fiscal_year_period ;; + } + + +} diff --git a/views/profit_and_loss_hierarchy_selection_sdt.view.lkml b/views/profit_and_loss_hierarchy_selection_sdt.view.lkml new file mode 100644 index 00000000..4a68848a --- /dev/null +++ b/views/profit_and_loss_hierarchy_selection_sdt.view.lkml @@ -0,0 +1,125 @@ +#########################################################{ +# This SQL Derived Table (sdt): +# 1) Takes user inputs from parameters: +# parameter_pick_start_level - select top level of hierarchy to show +# parameter_pick_depth_level - how many levels should be shown (1 to 5 levels) +# 2) Derives node_text and node values for hier1 to hier5 by placing the top level selected by user into hier_1 and subsequent levels into hier2 to hier5 +# 3) Filters applied: +# first level of the hierarchy = top level selected AND +# (level number = last level selected by user OR +# level number < last level AND GLIsLeafNode = true) +# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level AND +# levels 2 and 3 where GLIsLeafNode = true will also be selected +# +# If more than 5 hierarchy levels are needed, update the parameter_pick_depth_level and add additional hierN dimensions for node and node_text +# +# EXTENDED FIELDS: +# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext: +# parameter_pick_start_level +# parameter_pick_depth_level +# hier1_node_text ... hier5_node_text +# hier1_node ... hier5_node +# +# This view should be joined to profit_and_loss using an inner join on: +# client_mandt +# glhierarchy +# chart_of_accounts +# language_key_spras +# glnode +#########################################################} + +include: "/views/profit_and_loss_path_to_node_pdt.view" +include: "/views/common_hierarchy_fields_finance_ext.view" + +view: profit_and_loss_hierarchy_selection_sdt { + extends: [common_hierarchy_fields_finance_ext] + label: "Income Statement" + + fields_hidden_by_default: yes + + derived_table: { + sql: + {% assign top_level = parameter_pick_start_level._parameter_value | times: 1 %} + {% assign offset_start = top_level | minus: 2 %} + {% assign depth = parameter_pick_depth_level._parameter_value | times: 1 | minus: 1 %} + {% assign last_level = top_level | plus: depth %} + SELECT + h.Client, + h.ChartOfAccounts, + h.GLHierarchy, + LanguageKey_SPRAS, + LevelNumber, + LevelSequenceNumber, + GLIsLeafNode, + GLNode, + GLNodeText, + NodeTextPath_String, + NodePath_String, + NodeTextPath[SAFE_OFFSET({{offset_start}})] AS hier1_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 1}})] AS hier2_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 2}})] AS hier3_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 3}})] AS hier4_node_text, + NodeTextPath[SAFE_OFFSET({{offset_start | plus: 4}})] AS hier5_node_text, + NodePath[SAFE_OFFSET({{offset_start}})] AS hier1_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 1}})] AS hier2_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 2}})] AS hier3_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 3}})] AS hier4_node, + NodePath[SAFE_OFFSET({{offset_start | plus: 4}})] AS hier5_node, + NodeTextPath[SAFE_OFFSET({{offset_start}})] AS top_hier_level + FROM ${profit_and_loss_path_to_node_pdt.SQL_TABLE_NAME} h + WHERE NodeLevelPath[SAFE_OFFSET({{offset_start}})] = '{{top_level}}' + AND ( LevelNumber = least({{last_level}},MaxLevelNumber) OR + (LevelNumber < least({{last_level}},MaxLevelNumber) AND GLIsLeafNode = true) + ) + ;; + } + + dimension: key { + hidden: yes + type: string + primary_key: yes + sql: CONCAT(${client_mandt},${glhierarchy},${chart_of_accounts},${language_key_spras},${glnode}) ;; + } + + # Update with correct suggest explore and dimension (note, must be a string dimension). + parameter: parameter_pick_start_level { + view_label: "🔍 Filters & 🛠 Tools" + suggest_explore: profit_and_loss + suggest_dimension: profit_and_loss.gllevel_string + } + + parameter: parameter_pick_depth_level { + view_label: "🔍 Filters & 🛠 Tools" + } + + dimension: client_mandt { + type: string + sql: ${TABLE}.client ;; + } + + dimension: chart_of_accounts { + type: string + sql: ${TABLE}.ChartOfAccounts ;; + } + + dimension: glhierarchy { + type: string + sql: ${TABLE}.GLHierarchy ;; + } + + dimension: language_key_spras { + type: string + sql: ${TABLE}.LanguageKey_SPRAS ;; + } + + dimension: glnode { + type: string + sql: ${TABLE}.glnode ;; + } + + dimension: glnode_text { + type: string + sql: ${TABLE}.GLNodeText ;; + } + +} diff --git a/views/profit_and_loss_navigation_ext.view.lkml b/views/profit_and_loss_navigation_ext.view.lkml new file mode 100644 index 00000000..489bb08b --- /dev/null +++ b/views/profit_and_loss_navigation_ext.view.lkml @@ -0,0 +1,167 @@ +#########################################################{ +# Extends and modifies navigation_template to support navigation between +# related Income Statement Dashboards: With Comparisons and No Comparisons +# +# Two sets of LookML dashboards are included: +# - Marketplace Report Table With Comparisons (income_statement_mktplace_report_table) +# and Without Comparisons (income_statement_mktplace_report_table_no_comparisons) +# - Subtotal Table With Comparisons (income_statement_subtotal_table) +# and Without Comparisons (income_statement_subtotal_table_no_comparisons) +# +# Because of these two sets of dashboards ADDED a parameter navigation_which_dashboard_style +# to dynamically derive LookML dashboard name based on parameter setting +# +# Other customizations: +# dash_bindings: added dashboard and link names +# filter_bindings: added 8 filters and corresponding URL values +# filter label URL format +# ------- --------------- --------------------- +# filter1 Hierarchy Hierarchy +# filter2 Display Timeframe Display+Timeframe +# filter3 Select Fiscal Timeframe Select+Fiscal+Timeframe +# filter4 Global Currency Global+Currency +# filter5 Company Company +# filter6 Ledger Name Ledger+Name +# filter7 Top Hierarchy Level to Display Top+Hierarchy+Level+to+Display +# filter8 Combine Selected Timeframes? Combine+Selected+Timeframes%3F +# +# tip: to find URL formats copy url for dashboard and review list of parameters after +# [dashboard name]? +# +# filter1 to filter8 filters: added labels as indicated above (NOTE: can optionally unhide) +# navigation_focus_page: confirmed allowed values of 1 or 2 +# added group_label = "Navigation" for parameters exposed in the Explore +# +# To use this view: +# 1) Add to an explore using a bare join +# explore: profit_and_loss { +# join: profit_and_loss_navigation_ext { +# view_label: "🔍 Filters & 🛠 Tools" +# relationship: one_to_one +# sql: ;; +# }} +# +# 2) Add Navigation to Single Value Visualization and set these paramaters accordingly +# Navigation Style = small +# Navigation Focus Page = 1 (if adding to first dashboard listed, set to 2 if added viz to second dashboard) +# Which Dashboard Style? = subtotal (if adding to one of the subtotal dashboards) +# +# 3) Add Navigation visualization to a dashboard and set to map to listen to the dashboard filters +# +# Below is example Dashboard LookML generated: +# - title: navigation +# name: navigation +# explore: profit_and_loss +# type: single_value +# fields: [profit_and_loss_navigation_ext.navigation] +# filters: +# profit_and_loss_navigation_ext.navigation_focus_page: '1' +# profit_and_loss_navigation_ext.navigation_style: 'small' +# profit_and_loss_navigation_ext.navigation_which_dashboard_style: 'subtotal' +# show_single_value_title: false +# show_comparison: false +# listen: +# Hierarchy: profit_and_loss_navigation_ext.filter1 +# Display Timeframe: profit_and_loss_navigation_ext.filter2 +# Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 +# Global Currency: profit_and_loss_navigation_ext.filter4 +# Company: profit_and_loss_navigation_ext.filter5 +# Ledger Name: profit_and_loss_navigation_ext.filter6 +# Top Hierarchy Level to Display: profit_and_loss_navigation_ext.filter7 +# Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 +#########################################################} + + +include: "/views/navigation_template.view" + +view: profit_and_loss_navigation_ext { + extends: [navigation_template] + + dimension: dash_bindings { + hidden: yes + type: string + sql: 'income_statement_{% parameter navigation_which_dashboard_style %}_table|With Comparisons||income_statement_{% parameter navigation_which_dashboard_style %}_table_no_comparison|No Comparisons' ;; + } + + parameter: navigation_which_dashboard_style { + type: unquoted + group_label: "Navigation" + label: "Which Dashboard Style to Use?" + description: "Pick one of the two possible dashboards styles defined for Income Statement: Table with Subtotals or Report Table from Marketplace" + allowed_value: {label:"Marketplace Table (Report)" value:"mktplace_report"} + allowed_value: {label: "Subtotal Table" value:"subtotal" } + default_value: "subtotal" + } + + dimension: filter_bindings { + hidden: yes + type: string + # sql: 'filter1|Display+Timeframe' ;; + sql: 'filter1|Hierarchy||filter2|Display+Timeframe||filter3|Select+Fiscal+Timeframe||filter4|Global+Currency||filter5|Company||filter6|Ledger+Name||filter7|Top+Hierarchy+Level||filter8|Combine+Selected+Timeframes%3F' ;; + } + + parameter: navigation_focus_page { + hidden: no + type: unquoted + group_label: "Navigation" + allowed_value: {value:"1"} + allowed_value: {value:"2"} + default_value: "1" + } + + parameter: navigation_style { + hidden: no + group_label: "Navigation" + } + + filter: filter1 { + hidden: yes + type: string + label: "Hierarchy" + } + + filter: filter2 { + hidden: yes + type: string + label: "Display Timeframe" + } + + filter: filter3 { + hidden: yes + type: string + label: "Select Fiscal Timeframe" + } + + filter: filter4 { + hidden: yes + type: string + label: "Global Currency" + } + + filter: filter5 { + hidden: yes + type: string + label: "Company" + } + + filter: filter6 { + hidden: yes + type: string + label: "Ledger Name" + } + + filter: filter7 { + hidden: yes + type: string + label: "Top Hierarchy Level" + } + + filter: filter8 { + hidden: yes + type: string + label: "Combine Selected Timeframes?" + } + + + +} diff --git a/views/profit_and_loss_path_to_node_pdt.view.lkml b/views/profit_and_loss_path_to_node_pdt.view.lkml new file mode 100644 index 00000000..fb7e5fde --- /dev/null +++ b/views/profit_and_loss_path_to_node_pdt.view.lkml @@ -0,0 +1,117 @@ +#########################################################{ +# this Persistent Derived Table (pdt) derives the full path to a node (e.g., Net Income (P&L)/Operating Income/Gross Margin) +# +# Uses RECURSIVE to navigate the parent-child relationships and derive the full path +# This view is only referenced in the view profit_and_loss_hierarchy_selection_sdt +#########################################################} + +view: profit_and_loss_path_to_node_pdt { + derived_table: { + datagroup_trigger: profit_and_loss_node_count + create_process: { + sql_step: + + CREATE OR REPLACE TABLE ${SQL_TABLE_NAME} as + WITH + RECURSIVE n AS ( + SELECT + Client, + ChartOfAccounts, + GLHierarchy, + LanguageKey_SPRAS, + GLLevel, + CAST(GLLevel AS INT64) AS LevelNumber, + GLParent, + COALESCE(GLParentText,GLParent) AS GLParentText, + GLNode, + COALESCE(GLNodeText,GLNode) AS GLNodeText, + GLIsLeafNode + FROM + `@{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss` + GROUP BY + Client, + ChartOfAccounts, + GLHierarchy, + LanguageKey_SPRAS, + GLLevel, + CAST(GLLevel AS INT64), + GLParent, + COALESCE(GLParentText,GLParent), + GLNode, + COALESCE(GLNodeText,GLNode), + GLIsLeafNode + ), + iterations AS ( + SELECT + Client, + ChartOfAccounts, + GLHierarchy, + LanguageKey_SPRAS, + GLLevel, + LevelNumber, + GLIsLeafNode, + GLNode, + GLNodeText, + GLParent, + GLParentText, + 0 AS LevelSequenceNumber, + GLnodeText AS NodeTextPath_String, + GLNode AS NodePath_String, + CAST(LevelNumber as STRING) AS NodeLevelPath_String + FROM + n + WHERE + LevelNumber = 2 + UNION ALL + SELECT + n.Client, + n.ChartOfAccounts, + n.GLHierarchy, + n.LanguageKey_SPRAS, + n.GLLevel, + n.LevelNumber, + n.GLIsLeafNode, + n.GLNode, + n.GLNodeText, + n.GLParent, + n.GLParentText, + LevelSequenceNumber+1 AS LevelSequenceNumber, + CONCAT(NodeTextPath_String, '-->',n.GLNodeText) AS NodeTextPath_String, + CONCAT(NodePath_String, '-->',n.GLNode) AS NodePath_String, + CONCAT(NodeLevelPath_String, '-->',CAST(n.LevelNumber AS STRING)) AS NodeLevelPath_String + FROM + n + JOIN + iterations i + ON + i.GLNode = n.GLParent + AND i.Client = n.Client + AND i.ChartOfAccounts = n.ChartOfAccounts + AND i.GLHierarchy = n.GLHierarchy + AND i.LanguageKey_SPRAS = n.LanguageKey_SPRAS + AND i.LevelSequenceNumber < 12 + ) + SELECT Client, + ChartOfAccounts, + GLHierarchy, + LanguageKey_SPRAS, + GLLevel, + GLIsLeafNode, + GLNode, + GLNodeText, + GLParent, + GLParentText, + LevelNumber, + LevelSequenceNumber, + MAX(LevelNumber) OVER (PARTITION BY Client,ChartOfAccounts,GLHierarchy) AS MaxLevelNumber, + NodeTextPath_String, + NodePath_String, + NodeLevelPath_String, + SPLIT(NodeTextPath_String,'-->') AS NodeTextPath, + SPLIT(NodePath_String,'-->') AS NodePath, + SPLIT(NodeLevelPath_String,'-->') AS NodeLevelPath + FROM iterations + ;; + } + } +} diff --git a/views/profit_and_loss_rfn.view.lkml b/views/profit_and_loss_rfn.view.lkml new file mode 100644 index 00000000..3ae8ed6e --- /dev/null +++ b/views/profit_and_loss_rfn.view.lkml @@ -0,0 +1,325 @@ +#########################################################{ +# With this reporting view, users can report on any of the FSV nodes and corresponding amounts will be rolled up or down according to node values +# +# aggregation of General Ledger Transactions by the following dimensions: +# Client +# Fiscal Year +# Fiscal Period +# Company Code +# Chart of Accounts +# Hierarchy Name +# Business Area +# Profit Center +# Cost Center +# Ledger +# Hierarchy Node +# Languague +# Global (Target) Currency +# +# Measures: +# Amount in Local Currency, Amount in Global Currency +# Cumulative Amount in Local Currency, Cumulative Amount in Global Currency +# Exchange Rate (based on last date in the period) +# Avg Exchange Rate, Max Exchange Rate +# +# To query this table, filter to: +# - a single Client MANDT (handled with Constant defined in Manifest file) +# - a single Language (the Explore based on this view uses User Attribute locale to select language in joined view language_map_sdt) +# - a single Global Currency +# - a single Hierarchy Name or Financial Statement Version +# - a single Company +# +# Extends common dimensions found in both balance sheet and profit and loss using view common_fields_finance_ext +# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, +# fiscal_period, fiscal_quarter, fiscal_year and related fields +# Make changes to these dimensions in view common_fields_finance_ext if changes are for both balance sheet and profit and loss or; +# Customize these dimensions specifically for Profit and Loss in this view as needed +#########################################################} + + +include: "/views/profit_and_loss_base.view" +include: "/views/common_fields_finance_ext.view" + +view: +profit_and_loss { + extends: [common_fields_finance_ext] + + label: "Income Statement" + + dimension: key { + primary_key: yes + hidden: yes + sql: CONCAT(${client},${company_code}, ${chart_of_accounts}, ${glhierarchy}, + COALESCE(${business_area},'null') ,COALESCE(${ledger_in_general_ledger_accounting},'0L'), + COALESCE(${profit_center},'null'),COALESCE(${cost_center},'null') + ,${glnode},${fiscal_year},${fiscal_period},${language_key_spras},${target_currency_tcurr});; + } + +######################################################### +# Parameters & Filters for Income Statement Dashboard and related dimensions +#{ +# 4 parameters: +# parameter_display_time_dimension +# filter_fiscal_timeframe +# parameter_compare_to +# parameter_aggregate +# +# 2 related dimensions: +# timeframes_list - based on selection for parameter_display_time_dimension will show either fiscal_year, fiscal_year_quarter_label, fiscal_year_period +# +######################################################### + + parameter: parameter_display_time_dimension { + type: unquoted + view_label: "🔍 Filters & 🛠 Tools" + label: "Display Year, Quarter or Period" + allowed_value: {label: "Fiscal Period" value: "fp"} + allowed_value: {label: "Quarter" value: "qtr"} + allowed_value: {label: "Year" value: "yr"} + default_value: "qtr" + } + + # this filter is intended for use on a dashboard only and should be linked to parameter_display_time_dimension + # so that values in drop-down populate correctly based on the time display selected + # note, when used in an explore this filter may not reflect changes in parameter_display_time_dimension + # this filter is applied in view profit_and_loss_hierarchy_selection_sdt (which is joined to this view in the Explore profit_and_loss) + filter: filter_fiscal_timeframe { + type: string + view_label: "🔍 Filters & 🛠 Tools" + description: "Choose fiscal periods, quarters or years for Income Statement Reporting. To ensure the correct timeframes are listed, add this filter to a dashboard. Add the parameter \'Display Fiscal Period or Quarter\' and select this filter to update when the display parameter changes." + label: "Select Fiscal Timeframe" + suggest_dimension: timeframes_list + } + + parameter: parameter_aggregate { + type: unquoted + view_label: "🔍 Filters & 🛠 Tools" + label: "Combine Selected Timeframes?" + description: "If multiple timeframes selected, should results be combined or shown for each time period selected?" + allowed_value: {value: "Yes"} + allowed_value: {value: "No"} + default_value: "Yes" + } + + parameter: parameter_compare_to { + type: unquoted + view_label: "🔍 Filters & 🛠 Tools" + label: "Select Comparison Type" + allowed_value: { + label: "None" value: "none" + } + allowed_value: { + label: "Year Ago" value: "yoy" + } + allowed_value: { + label: "Previous Fiscal Timeframe" value: "prior" + } + default_value: "none" + } + + dimension: timeframes_list { + hidden: yes + view_label: "🔍 Filters & 🛠 Tools" + label: "Timeframe" + description: "Used to populate filter labeled Select Fiscal Timeframe. Timeframes listed depend on whether displaying Fiscal Periods, Quarters or Years in the Income Statement dashboards." + sql: {% assign display = parameter_display_time_dimension._parameter_value %} + {% if display == 'yr' %}${fiscal_year} + {% elsif display == 'qtr' %}${fiscal_year_quarter_label} + {% else %}${fiscal_year_period} + {% endif %} + ;; + order_by_field: selected_timeframe_level_as_negative_number + } + + dimension: selected_timeframe_level_as_negative_number { + hidden: yes + description: "Used to sort timeframes shown (fiscal periods, quarters or years) in descending order." + sql: {% assign display = parameter_display_time_dimension._parameter_value %} + {% if display == 'yr' %}${fiscal_year_negative_number} + {% elsif display == 'qtr' %}${fiscal_year_quarter_negative_number} + {% else %}${fiscal_year_period_negative_number} + {% endif %};; + } + +#} end parameters & filters + + +######################################################### +# GL Hierarchy, Level, Parent and Node dimensions +# { + + dimension: glhierarchy { + label: "GL Hierarchy" + description: "GL Hierarchy Name is same as Financial Statement Version (FSV)" + } + + dimension: gllevel { + label: "GL Level" + description: "GL Hierarchy level of the Child Node represents logical classification within a Chart of Accounts and Includes the Parent-Child Relationship." + } + + dimension: gllevel_number { + type: number + label: "GL Level (number)" + description: "GL Level as a numeric. GL Hierarchy level of the Child Node represents logical classification within a Chart of Accounts and Includes the Parent-Child Relationship." + sql: PARSE_NUMERIC(${gllevel}) ;; + } + + # used as input into parameter Top Level of Hierarchy to Show + dimension: gllevel_string { + type: string + hidden: yes + label: "Level" + description: "GL Level as a string. GL Hierarchy level of the Child Node represents logical classification within a Chart of Accounts and Includes the Parent-Child Relationship." + sql: LTRIM(${gllevel},'0') ;; + } + + dimension: glnode { + label: "GL Node (code)" + description: "General Ledger Child Node as a code value." + } + + dimension: glnode_text { + label: "GL Node (text)" + description: "General Ledger Child Node as a descriptive name." + order_by_field: glnode + } + + dimension: glparent { + label: "GL Parent (code)" + description: "Within a given GL Level, the Parent Node of the Child Node as a code value." + } + + dimension: glparent_text { + label: "GL Parent (text)" + description: "Within a given GL Level, the Parent Node of the Child Node as a descriptive name." + order_by_field: glparent + } + + dimension: glfinancial_item { + label: "GL Financial Item" + description: "A single line-item entry within a GL account." + } + + dimension: glis_leaf_node { + type: yesno + label: "Is Leaf Node" + description: "Yes if GL Child Node is a Leaf Node." + } + + dimension: cost_center { + description: "Cost Center" + } + + dimension: profit_center { + description: "Profit Center" + } + +#} end gl_dimensions + +######################################################### +# Amount dimensions with Sign Multiplier +# { +# Revenue is generally displayed in general ledger as a negative number, which indicates a credit. +# By setting the constant SIGN_CHANGE value to 'yes' in the project manifest, +# it's displayed as a positive number in income statement. +# +# Using the constant sign_change_multiplier (which uses SIGN_CHANGE constant), the appropriate multiplier is +# applied to the Amount dimensions below +# +# These dimensions are hidden from the explore and restated using measures +# + + dimension: amount_in_local_currency { + hidden: yes + sql: @{sign_change_multiplier} + ${TABLE}.AmountInLocalCurrency * {{multiplier}} ;; + } + + # based on value in CONSTANTs sign_change_multiplier flip the signs so Income is positive and Expenses negative + dimension: amount_in_target_currency { + hidden: yes + label: "Amount in Global Currency" + sql: @{sign_change_multiplier} + ${TABLE}.AmountInTargetCurrency * {{multiplier}} ;; + } + + dimension: cumulative_amount_in_local_currency { + hidden: yes + sql: @{sign_change_multiplier} + ${TABLE}.CumulativeAmountInLocalCurrency * {{multiplier}} ;; + } + + dimension: cumulative_amount_in_target_currency { + hidden: yes + label: "Cumulative Amount in Global Currency" + description: "End of Period Cumulative Amount in Global/Target Currency" + sql: @{sign_change_multiplier} + ${TABLE}.CumulativeAmountInTargetCurrency * {{multiplier}} ;; + } + +#} end amount dimensions + +######################################################### +# Measures +# { + + measure: count { + hidden: no + label: "Count of Rows" + } + + measure: total_amount_in_local_currency { + type: sum + label: "Total Amount (Local Currency)" + description: "Period Amount in Local Currency" + sql: ${amount_in_local_currency} ;; + # value_format_name: millions_d1 + } + + measure: total_cumulative_amount_in_local_currency { + hidden: yes + type: sum + label: "Total Cumulative Amount (Local Currency)" + description: "End of Period Cumulative Amount in Local Currency" + sql: ${cumulative_amount_in_local_currency} ;; + value_format_name: decimal_0 + # value_format_name: millions_d1 + } + + measure: total_amount_in_global_currency { + type: sum + label: "Total Amount (Global Currency)" + description: "Period Amount in Target or Global Currency" + sql: ${amount_in_target_currency} ;; + value_format_name: decimal_0 + # value_format_name: millions_d1 + } + + measure: total_cumulative_amount_in_global_currency { + hidden: yes + type: sum + label: "Total Cumulative Amount (Global Currency)" + description: "End of Period Cumulative Amount in Target or Global Currency" + sql: ${cumulative_amount_in_target_currency} ;; + value_format_name: decimal_0 + # value_format_name: millions_d1 + } + + measure: net_income { + type: sum + hidden: no + label: "Total Net Income (Global Currency)" + sql: ${amount_in_target_currency} ;; + filters: [gllevel_number: "2"] + value_format_name: millions_d1 + } + + measure: list_fiscal_periods { + type: list + list_field: fiscal_year_period + } + + #} end measures + + +} From 4571a38613bc96bf9c898ec4fd458a020176c926 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 20 Mar 2024 01:41:55 +0000 Subject: [PATCH 03/16] update README and RELEASE_NOTES --- README.md | 16 +++++++++++++++- RELEASE_NOTES.md | 13 +++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cb9d114..6d0a1ed0 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,18 @@ View the balance sheet as of a selected fiscal period, compared to the same peri - **Balance Sheet Marketplace Report** - This report uses an easy-to-read table style designed for finance reports. To use this dashboard, a Looker Admin must install the [Report Table](https://marketplace.looker.com/marketplace/detail/viz-report_table) plug-in/visualization type from Looker Marketplace. Refer to Looker documentation for [Using Looker Marketplace](https://cloud.google.com/looker/docs/marketplace). -- **Balance Sheet Subtotals Report** - This report uses Looker's built-in table visualization with subtotals (no special installation required). +- **Balance Sheet Subtotals Report** - This report uses Looker's built-in table visualization with subtotals (no special installation required). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons. + +

Income Statement

+ +> ⚠️ available beginning with [Google Cloud Cortex Framework 5.4](https://github.com/GoogleCloudPlatform/cortex-data-foundation). + +View the income statement for select fiscal periods (individually or combined). Compare timeframe to the same timeframe a year ago or the previous fiscal timeframe. And display 3-levels of the selected hierarchy for a company. Two set dashboards using different table styles and including/excluding comparisons are provided. + + +- **Income Statement Marketplace Report** - This report uses an easy-to-read table style designed for finance reports. To use this dashboard, a Looker Admin must install the [Report Table](https://marketplace.looker.com/marketplace/detail/viz-report_table) plug-in/visualization type from Looker Marketplace. Refer to Looker documentation for [Using Looker Marketplace](https://cloud.google.com/looker/docs/marketplace). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons. + +- **Income Statement Subtotals Report** - This report uses Looker's built-in table visualization with subtotals (no special installation required). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons.

Required Data

@@ -78,6 +89,9 @@ With the Looker project based on your forked repository, you can customize the L - **Client**: The SAP Client number (mandt) to use for Reporting. +- **Sign Change**: For Profit and Loss/Income Statement reporting, revenue is generally displayed in general ledger as a negative number, which indicates a credit. By setting Sign Change value to 'yes', it's displayed as a positive number in income statement reports. + +

Required User Attributes

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9672befe..07930124 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,16 @@ +## Release v5.4 +* Balance Sheet: + * Improved fields descriptions and organization within the Balance Sheet Explore + * Updated underlying logic for hierarchy levels to display the selected top level and its subordinate levels, rather than just the lowest level + * Added navigation to Subtotals dashboards with and without comparisons to year ago, prior fiscal period or custom period + * Updated underlying logic for deriving comparison period to eliminate reliance on `max_fiscal_period` constant + * Added context to view definitions with more-detailed comments + * Added Balance Sheet dashboard template to minimize edits to filters and other shared elements + +* Profit and Loss / Income Statement: + * Added views, explores and dashboards to support `Income Statement` reporting + * Added a required constant to provide flexibility in how revenue amounts appear in reporting. To display revenue as positive, set the value of `SIGN_CHANGE` constant to `yes` + ## Release v5.3.1 * Balance Sheet Updates: * Added the Persistent Derived Table (PDT) view `balance_sheet_path_to_node_pdt` and Datagroup `balance_sheet_node_count`. This PDT finds the full hierarchy path to each Balance Sheet node (e.g., Assets/Current Assets/Cash & Equivalents). This PDT will regenerate if the count of Client, Chart of Accounts, Hierarchy Name, Level, and Node changes. Requires BigQuery connection used for this LookML model to have [Persistent Derived Tables](https://cloud.google.com/looker/docs/db-config-google-bigquery#persistent-derived-tables-on-a-connection) enabled. From 17d33b2af910aa82798d44ff2fc78337e1ca5312 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 20 Mar 2024 04:24:22 +0000 Subject: [PATCH 04/16] balance sheet change title of dashboard; adjust title summary --- ...alance_sheet_mktplace_report_table.dashboard.lookml | 2 +- .../balance_sheet_subtotal3_table.dashboard.lookml | 2 +- ...heet_subtotal3_table_no_comparison.dashboard.lookml | 2 +- manifest.lkml | 2 +- ...t_and_loss_03_selected_fiscal_periods_sdt.view.lkml | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml index b6655d14..9c903e70 100644 --- a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml @@ -6,7 +6,7 @@ #########################################################} - dashboard: balance_sheet_mktplace_report_table - title: Financial Statement Balance Sheet + title: Financial Balance Sheet layout: newspaper preferred_viewer: dashboards-next filters_location_top: false diff --git a/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml index 488d8c7d..7e3d27e1 100644 --- a/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml @@ -8,7 +8,7 @@ #########################################################} - dashboard: balance_sheet_subtotal3_table - title: Financial Statement Balance Sheet + title: Financial Balance Sheet layout: newspaper preferred_viewer: dashboards-next description: Using standard table with subtotals, reports Fiscal Period Cumulative diff --git a/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml b/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml index 9e9b98a2..4fe9b3b0 100644 --- a/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_subtotal3_table_no_comparison.dashboard.lookml @@ -9,7 +9,7 @@ #########################################################} - dashboard: balance_sheet_subtotal3_table_no_comparison - title: Financial Statement Balance Sheet + title: Financial Balance Sheet layout: newspaper preferred_viewer: dashboards-next description: "Using standard table with subtotals, reports Fiscal Period Cumulative Amount in Global Currency for the selected hierarchy, chart of accounts, company, and fiscal period." diff --git a/manifest.lkml b/manifest.lkml index d4b1d3f1..3f470146 100644 --- a/manifest.lkml +++ b/manifest.lkml @@ -4,7 +4,7 @@ constant: CONNECTION_NAME { } constant: GCP_PROJECT { - value: "GCP Project Name" + value: "GCP Project ID" export: override_required } diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index e3b8d2fb..2ec9f0d4 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -350,12 +350,12 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { hidden: no sql: 1 ;; html: -
- Income Statement
- {{profit_and_loss.company_text._value}}
- Reporting Fiscal Timeframe: {{reporting_timeframes_list_with_partial_indicator._value}}    Net Income: {{profit_and_loss.net_income._rendered_value}}M + ;; } From d20d9934f401ee5b161d1b08076d7ecd818e0f3f Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 20 Mar 2024 04:32:46 +0000 Subject: [PATCH 05/16] adjust title summary font size --- views/balance_sheet_rfn.view.lkml | 10 +++++----- ...t_and_loss_03_selected_fiscal_periods_sdt.view.lkml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/views/balance_sheet_rfn.view.lkml b/views/balance_sheet_rfn.view.lkml index dfbe0b39..4f32c9cd 100644 --- a/views/balance_sheet_rfn.view.lkml +++ b/views/balance_sheet_rfn.view.lkml @@ -240,12 +240,12 @@ view: +balance_sheet { description: "Used in Balance Sheet dashboard as Summary visualization with Company, Global Currency, Fiscal Period and Current Ratio. Add this measure to a single-value visualizaiton." sql: 1 ;; html: -
- Balance Sheet
- {{company_text._value}}
- Fiscal Period: {{select_fiscal_period._parameter_value}}    Current Ratio: {{current_ratio._rendered_value}} + ;; } diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index 2ec9f0d4..5d7ac3de 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -351,11 +351,11 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { sql: 1 ;; html: ;; } From b5b221cf9d35848cbe02a7cb97f5a22de07969a6 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 20 Mar 2024 14:48:04 +0000 Subject: [PATCH 06/16] update title summary font size --- views/balance_sheet_rfn.view.lkml | 10 +++++----- ...t_and_loss_03_selected_fiscal_periods_sdt.view.lkml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/views/balance_sheet_rfn.view.lkml b/views/balance_sheet_rfn.view.lkml index 4f32c9cd..dce136ca 100644 --- a/views/balance_sheet_rfn.view.lkml +++ b/views/balance_sheet_rfn.view.lkml @@ -240,12 +240,12 @@ view: +balance_sheet { description: "Used in Balance Sheet dashboard as Summary visualization with Company, Global Currency, Fiscal Period and Current Ratio. Add this measure to a single-value visualizaiton." sql: 1 ;; html: -
- Balance Sheet
- {{company_text._value}}
- Fiscal Period: {{select_fiscal_period._parameter_value}}    Current Ratio: {{current_ratio._rendered_value}} + ;; } diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index 5d7ac3de..e3a15907 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -351,11 +351,11 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { sql: 1 ;; html: ;; } From 08234ddf6961029a479024880a1fb75c19a6fc87 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Thu, 21 Mar 2024 20:14:20 +0000 Subject: [PATCH 07/16] subtotals: fixed sorting issue causing incorrect totals to appear --- views/common_hierarchy_fields_finance_ext.view.lkml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/views/common_hierarchy_fields_finance_ext.view.lkml b/views/common_hierarchy_fields_finance_ext.view.lkml index 5d909e7b..2d56768f 100644 --- a/views/common_hierarchy_fields_finance_ext.view.lkml +++ b/views/common_hierarchy_fields_finance_ext.view.lkml @@ -69,6 +69,7 @@ view: common_hierarchy_fields_finance_ext { label: "Hierarchy Node 2" description: "Node (text) for 2nd Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" sql: COALESCE(${TABLE}.hier2_node_text,' ') ;; + # sql: COALESCE(${TABLE}.hier2_node_text,${TABLE}.hier1_node_text) ;; order_by_field: hier2_node } @@ -79,6 +80,7 @@ view: common_hierarchy_fields_finance_ext { label: "Hierarchy Node 3" description: "Node (text) for 3rd Hierarchy Level as set with the parameter 'Select Top Hierarchy Level to Display'" sql: COALESCE(${TABLE}.hier3_node_text,' ') ;; + # sql: COALESCE(${TABLE}.hier3_node_text,${TABLE}.hier2_node_text) ;; order_by_field: hier3_node } @@ -105,30 +107,30 @@ view: common_hierarchy_fields_finance_ext { dimension: hier1_node { hidden: yes type: string - sql: ${TABLE}.hier1_node ;; + sql: UPPER(${TABLE}.hier1_node) ;; } dimension: hier2_node { hidden: yes type: string - sql: ${TABLE}.hier2_node ;; + sql: UPPER(COALESCE(${TABLE}.hier2_node,'ZZZZ')) ;; } dimension: hier3_node { hidden: yes type: string - sql: ${TABLE}.hier3_node ;; + sql: UPPER(COALESCE(${TABLE}.hier3_node,'ZZZZ')) ;; } dimension: hier4_node { hidden: yes type: string - sql: ${TABLE}.hier4_node ;; + sql: UPPER(COALESCE(${TABLE}.hier4_node,'ZZZZ') ;; } dimension: hier5_node { hidden: yes type: string - sql: ${TABLE}.hier5_node ;; + sql: UPPER(COALESCE(${TABLE}.hier5_node),'ZZZZ') ;; } } From d22c57db0cbb69db1cc0646877a04f53270a97c2 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Fri, 22 Mar 2024 02:06:22 +0000 Subject: [PATCH 08/16] Update language_map_sdt to default to English if user's locale does not match SAP code or is not in BalanceSheet or ProfitAndLoss --- views/language_map_sdt.view.lkml | 84 ++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/views/language_map_sdt.view.lkml b/views/language_map_sdt.view.lkml index aaaed3d8..a726238d 100644 --- a/views/language_map_sdt.view.lkml +++ b/views/language_map_sdt.view.lkml @@ -1,38 +1,66 @@ -###################### -# this sdt view filters Languages_T002 base on the `locale` user attribute value +#########################################################{ +# Filters Languages_T002 to single row based on the `locale` user attribute value. +# If user does not have a locale value or if the user's locale is not one of the +# Languages used for Balance Sheet or Profit and Loss, # -# `locale` user attribute is used to Localize a LookML Model and impact -# language used for labels or number formatting -# the supported user-interface languages with the Looker Locale Code are found here: +# The `locale` user attribute is used to Localize a LookML Model and impacts +# language used for User Interface, labels and/or number formatting. +# The supported user-interface languages with the Looker Locale Code are found here: # https://cloud.google.com/looker/docs/supported-user-interface-languages#localizing_the_looker_user_interface # -# if Looker has not been set up for Localization, admin will still need to add a user_attribute named `locale` -# with default value of 'en' or 'EN'. And they will need to assign users or user groups values for either: +# If Looker has not been configured for Localization, admin will need to add +# a user_attribute named `locale` with default value of 'en' or 'EN'. +# And admin will need to assign users or user groups values using: # Looker Locale Code or -# SAP LAISO code (two-character SAP language Code +# SAP LAISO code (two-character SAP language Code) # -# this view captures the user_attribute value and uses liquid to convert it to LAISO two-character value with logic: -# - read user_attribute value (for this example, user_attribute = 'es_ES') -# - create an array using split user attribute value by '_' and applying uppercase (see locale_key) -# - if first value of array (locale_key[0]) = 'NB' set locale to 'NO' -# - else set locale = to first value of array -# - return the value for locale and inject into where clause -# where = TwoCharacterSapLanguageCode_LAISO = 'ES' +# Steps in the dynamic generation of SQL based on user's locale +# (for this example, user's locale = 'es_ES'): +# 1. Capture user's value in locale user attribute and: +# - replace 'nb' with 'no' (so Norweign locale string parse correctly to SAP LAISO code) +# - convert to UPPER case +# - split into array on '_' (first value of array will be used in SQL) +# 2. Generate WHERE clause using first value of locale array: +# WHERE TwoCharacterSapLanguageCode_LAISO = 'ES' +# 3. If the languague_map_sdt view used in either Balance Sheet or Profit and Loss Explores, +# add another condition to WHERE clause: +# AND LanguagueKey_SPRAS in (select distinct languageKey_SPRAS FROM BalanceSheet (or ProfitAndLoss)) +# 4. To ensure English is used if locale value does not match SAP LAISO code or not part of +# Balance Sheet or Profit and Loss data, add UNION ALL to always include English as a row +# UNION ALL SELECT 'E' as LanguageKey_SPRAS +# 5. Limit to only 1 row, keeping a valid locale value first and English second # -# use this view as inner join to BalanceSheet and others which require language_key_spras -###################### - +# JOIN this view as inner join to materials_MD and others which require language_key_spras +# For example: +# explore: profit_and_loss { +# always_join: [language_map_sdt] +# join: language_map_sdt { +# type: inner +# relationship: many_to_one +# sql_on: ${profit_and_loss.language_key_spras} = ${language_map_sdt.language_spras} ;; +# fields: [] +# }} +#########################################################} view: language_map_sdt { derived_table: { - sql: select LanguageKey_SPRAS as Language_SPRAS - ,TwoCharacterSapLanguageCode_LAISO - from `@{GCP_PROJECT}.@{REPORTING_DATASET}.Languages_T002` - where TwoCharacterSapLanguageCode_LAISO = - {% assign locale_key = _user_attributes['locale'] | split:'_' %} - {% if locale_key[0] == 'nb' %}{%assign locale = 'NO' %}{%else%}{%assign locale = locale_key[0] | upcase %}{% endif %} - '{{locale}}';; + sql: {% assign locale = _user_attributes['locale'] | replace: 'nb','no' | upcase | split: '_' %} + {% assign explore = _explore._name | replace: 'balance_sheet','BalanceSheet' | replace: 'profit_and_loss','ProfitAndLoss' %} + SELECT LanguageKey_SPRAS AS Language_SPRAS, + 1 as rnk + FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.Languages_T002` + WHERE TwoCharacterSapLanguageCode_LAISO = '{{locale[0]}}' + {% if explore == 'ProfitAndLoss' or explore == 'BalanceSheet' %} + AND LanguageKey_SPRAS IN ( + SELECT DISTINCT languageKey_SPRAS + FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.{{explore}}`) + {% endif %} + UNION ALL + SELECT 'E' as LanguageKey_SPRAS, 2 as rnk + ORDER BY rnk + LIMIT 1 + ;; } dimension: language_spras { @@ -42,10 +70,4 @@ view: language_map_sdt { sql: ${TABLE}.Language_SPRAS ;; } - dimension: two_character_sap_language_code_laiso { - label: "Two Character SAP Language Code LAISO" - type: string - sql: ${TABLE}.TwoCharacterSapLanguageCode_LAISO ;; - } - } From 4ea363e72cfc2d5f235d397ef72effadc769521d Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Fri, 22 Mar 2024 17:44:10 +0000 Subject: [PATCH 09/16] fix footnote issue and update code comments --- ...balance_sheet_fiscal_periods_sdt.view.lkml | 20 +++++--- ...heet_fiscal_periods_selected_sdt.view.lkml | 46 +++++++++++-------- ...ce_sheet_hierarchy_selection_sdt.view.lkml | 42 +++++++++++------ ...s_03_selected_fiscal_periods_sdt.view.lkml | 10 ++-- 4 files changed, 73 insertions(+), 45 deletions(-) diff --git a/views/balance_sheet_fiscal_periods_sdt.view.lkml b/views/balance_sheet_fiscal_periods_sdt.view.lkml index 26f9fc54..870a89d6 100644 --- a/views/balance_sheet_fiscal_periods_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_sdt.view.lkml @@ -1,15 +1,21 @@ #########################################################{ +# PURPOSE: # Finds the Fiscal Years and Periods available in Balance Sheet +# And derives the following fields: +# - fiscal_year_period +# - yoy_fiscal_period +# - prior_fiscal_year_period # -# derives the following fields which will be used to identify comparison period based on user selections -# in the view balance_sheet_fiscal_periods_selected: -# - fiscal_year_period -# - yoy_fiscal_period -# - prior_fiscal_year_period +# SOURCE: +# Table @{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet # -# note, no dimensions or measure are defined as this view is only intended to be used as a reference in another view +# REFERENCED IN: +# View balance_sheet_fiscal_periods_selected to identify comparison period based on user selections +# +# NOTE: no dimensions or measure are defined as this view is only referenced in another view #########################################################} + view: balance_sheet_fiscal_periods_sdt { derived_table: { sql: @@ -42,4 +48,4 @@ view: balance_sheet_fiscal_periods_sdt { } -} \ No newline at end of file +} diff --git a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml index 5fc82f6c..74d166ac 100644 --- a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml @@ -1,32 +1,38 @@ #########################################################{ -# Purpose: -# Takes user inputs from parameters to derive Reporting vs Comparison Period +# PURPOSE: +# Derives Reporting vs Comparison Periods based on user inputs # -# Keys to using this view: +# REFERENCED IN: +# Explore balance_sheet +# +# SOURCE: +# View balance_sheet_fiscal_periods_sdt +# +# KEYS TO USING: # - View label is "Reporting vs. Comparison Period" -# - Fields are hidden by default so must change hidden: property to no to include in an explore -# - includes references to fields from view balance_sheet so always join this view to balance_sheet using an inner join on: +# - Fields are hidden by default so must change "hidden: property" to "no" to include in an Explore +# - Measures includes references to fields from view balance_sheet so must join this view to balance_sheet using an inner join on: # hierarchy_name, company_code, fiscal_year, fiscal_period -# Note, the balance_sheet_fiscal_periods_sdt view already filters to the same Client id so it is not needed in the join. -# -# Steps taken: -# 1) Takes user inputs from parameters: -# balance_sheet.select_fiscal_period - user picks one fiscal period which becomes the "Reporting" period -# balance_sheet.select_compare_to - user picks to compare the Reporting period to either: same period a year ago, the prior fiscal period, a specific fiscal period or none -# balance_sheet.select_custom_comparison_period - if user picks a comparison to a custom fiscal period, user must select one fiscal period which becomes the "Comparison" period +# Note, the source view already filters to a single Client id so it is not needed in the join # -# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters that returns -# two fiscal periods representing the "Reporting" and "Comparison" periods. View balance_sheet_fiscal_periods_sdt is the source. +# PROCESS: +# 1) Captures inputs from parameters: +# balance_sheet.select_fiscal_period -- user selects a single "Reporting" fiscal period +# balance_sheet.select_compare_to -- user can compare the Reporting period to either: same period a year ago, the prior fiscal period, a specific fiscal period +# balance_sheet.select_custom_comparison_period -- if "Custom" comparison selected, user must select one "Comparison" fiscal period. Year ago used if no period provided + +# 2) Builds SQL statement based on parameter values selected. Returns the fiscal periods +# representing the "Reporting" and "Comparison" periods # -# 3) Derives new dimensions: +# 3) Derives these fields: # fiscal_period_group -- value of Reporting or Comparison # alignment_group_name -- equals the value of the selected reporting period # -# Derives these Measures to support Reporting vs. Comparison Period: -# reporting_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Reporting' -# comparison_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Comparison' -# difference_value -- reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency -# difference_percent -- (reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency) / abs(comparison_period_amount_in_global_currency) +# MEASURES: +# reporting_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Reporting' +# comparison_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Comparison' +# difference_value -- reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency +# difference_percent -- (reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency) / abs(comparison_period_amount_in_global_currency) # #########################################################} diff --git a/views/balance_sheet_hierarchy_selection_sdt.view.lkml b/views/balance_sheet_hierarchy_selection_sdt.view.lkml index 5f54c774..b64de05c 100644 --- a/views/balance_sheet_hierarchy_selection_sdt.view.lkml +++ b/views/balance_sheet_hierarchy_selection_sdt.view.lkml @@ -1,26 +1,42 @@ ######################################################### -# This SQL Derived Table (sdt): -# 1) Takes user inputs from parameters: -# parameter_pick_start_level - select top level of hierarchy to show -# parameter_pick_depth_level - how many levels should be shown (1 to 5 levels) +# PURPOSE +# SQL Derived Table (SDT) to select the Node levels to display in Balance Sheet report. Assigns values to Hier1_node_text to Heir5_node_text based on user inputs. +# +# SOURCES: +# View balance_sheet_path_to_node_pdt +# Extends View common_hierarchy_fields_finance_ext +# +# REFERENCED IN: +# Explore Balance Sheet +# +# PROCESS: +# 1) Captures inputs from parameters: +# parameter_pick_start_level -- select top level of hierarchy to show +# parameter_pick_depth_level -- how many levels should be shown (1 to 5 levels) # 2) Derives node_text and node values for hier1 to hier5 by placing the top level selected by user into hier_1 and subsequent levels into hier2 to hier5 -# 3) Filters applied: -# first level of the hierarchy = top level selected AND -# (level number = last level selected by user OR -# level number < last level AND IsLeafNode = true) -# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level AND -# levels 2 and 3 where IsLeafNode = true will also be selected +# 3) Filters to keep: +# Hier1_node = top level selected AND +# (Child Level Number = last level selected by user OR +# Child Level Number < last level AND IsLeafNode = true) +# +# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level. +# Additionally, levels 2 and 3, where IsLeafNode equals true, will also be selected. # -# If more than 5 hierarchy levels are needed, update the parameter_pick_depth_level and add additional hierN dimensions for node and node_text +# CAVEATS: +# If more than 5 hierarchy levels are needed: +# - update the parameter_pick_depth_level to accept additional values +# - add additional hierN SQL statements +# - add additional dimensions in this view OR in extended view common_hierarchy_fields_finance_ext if also needed in other views # # EXTENDED FIELDS -# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext and can be further customized for Balance Sheet reporting: +# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext +# and can be further customized for Balance Sheet reporting: # parameter_pick_start_level # parameter_pick_depth_level # hier1_node_text ... hier5_node_text # hier1_node ... hier5_node # -# This view should be joined to balance sheet using an inner join on: +# PRIMARY KEY: # client_mandt # hierarchy_name # chart_of_accounts diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index e3a15907..a8d59824 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -350,7 +350,7 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { hidden: no sql: 1 ;; html: -
+
Income Statement
{{profit_and_loss.company_text._value}}
Reporting Fiscal Timeframe: {{reporting_timeframes_list_with_partial_indicator._value}}    Net Income: {{profit_and_loss.net_income._rendered_value}}M @@ -365,17 +365,17 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { type: string hidden: no description: "Add this measure to a single-value visualization. Returns a footnote indicating if a partial timeframe is included in the report and if so, it's max fiscal period. Should be added to a single value visualization." - sql: MAX('1') ;; + sql: MAX('2') ;; html: {% if any_timeframe_is_partial._value == 'Yes' %}{% assign time_level = selected_time_level._value %}{% assign compare_to = profit_and_loss.parameter_compare_to._parameter_value %} {% assign note = '*' | append: time_level | append: ' To Date:' %}{% assign reporting_time = max_partial_timeframe_reporting._value %}{% assign reporting_max = ' through period ' | append: max_fiscal_period_in_partial_timeframe_reporting._value %} {% assign compare_max = ' through period ' | append: max_fiscal_period_in_partial_timeframe_comparison._value %} {% assign reporting_note = ' Reporting ' | append: reporting_time %} {% if compare_to == 'none' %}{% assign comparison_note = reporting_max %} - {% elsif compare_to == 'yoy' or time_level == 'Fiscal Year' %}{% assign comparison_note = ' & Year Ago comparison through period ' | append: reporting_max %} - {% elsif compare_to == 'prior' and time_level != 'Fiscal Year' %}{% assign comparison_note = reporting_max | append: ' & Comparison ' | append: max_partial_timeframe_comparison._value | append: ' through period ' | append: compare_max %} + {% elsif compare_to == 'yoy' or time_level == 'Fiscal Year' %}{% assign comparison_note = ' & Year Ago' | append: reporting_max %} + {% elsif compare_to == 'prior' and time_level != 'Fiscal Year' %}{% assign comparison_note = reporting_max | append: ' & Comparison ' | append: max_partial_timeframe_comparison._value | append: compare_max %} {% else %}{% assign comparison_note = ' '%} {% endif %} -
+
{{note}}{{reporting_note}}{{comparison_note}}
{% else %} {%endif%} ;; From 09a53fc6e8b12dad292fd716ab6af04c9c833542 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Fri, 22 Mar 2024 23:45:58 +0000 Subject: [PATCH 10/16] Added comments for balance sheet objects; multiple fixes based on solution manager feedback --- ...eet_mktplace_report_table.dashboard.lookml | 2 +- .../balance_sheet_template.dashboard.lookml | 2 +- ...ent_mktplace_report_table.dashboard.lookml | 1 + explores_finance/profit_and_loss.explore.lkml | 8 +- ...balance_sheet_fiscal_periods_sdt.view.lkml | 10 +- ...heet_fiscal_periods_selected_sdt.view.lkml | 16 +- ...ce_sheet_hierarchy_selection_sdt.view.lkml | 10 +- views/balance_sheet_navigation_ext.view.lkml | 64 +++--- .../balance_sheet_path_to_node_pdt.view.lkml | 22 +- views/balance_sheet_rfn.view.lkml | 36 ++-- views/common_fields_finance_ext.view.lkml | 11 +- ...mon_hierarchy_fields_finance_ext.view.lkml | 13 +- views/fiscal_periods_sdt.view.lkml | 66 ------ views/navigation_template.view.lkml | 198 ++++++++++-------- ...s_03_selected_fiscal_periods_sdt.view.lkml | 4 +- views/profit_and_loss_rfn.view.lkml | 2 +- 16 files changed, 241 insertions(+), 224 deletions(-) delete mode 100644 views/fiscal_periods_sdt.view.lkml diff --git a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml index 9c903e70..b8f3b437 100644 --- a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml @@ -49,7 +49,7 @@ useHeadings: false useShortName: false useUnit: false - groupVarianceColumns: false + groupVarianceColumns: true genericLabelForSubtotals: false indexColumn: false transposeTable: false diff --git a/LookML_Dashboard/balance_sheet_template.dashboard.lookml b/LookML_Dashboard/balance_sheet_template.dashboard.lookml index 0e122efd..3f2e3aee 100644 --- a/LookML_Dashboard/balance_sheet_template.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_template.dashboard.lookml @@ -129,7 +129,7 @@ allow_multiple_values: false required: true ui_config: - type: advanced + type: dropdown_menu display: popover explore: balance_sheet field: balance_sheet.company_text diff --git a/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml index 39b67975..6dbbbe3f 100644 --- a/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml @@ -55,6 +55,7 @@ label|profit_and_loss_hierarchy_selection_sdt.hier3_node_text: " " subtotalDepth: '1' style|profit_and_loss_03_selected_fiscal_periods_sdt.reporting_amount: black_red + label|profit_and_loss_03_selected_fiscal_periods_sdt.comparison_amount: style|profit_and_loss_03_selected_fiscal_periods_sdt.comparison_amount: black_red style|profit_and_loss_03_selected_fiscal_periods_sdt.difference_value: black_red style|profit_and_loss_03_selected_fiscal_periods_sdt.difference_percent: black_red diff --git a/explores_finance/profit_and_loss.explore.lkml b/explores_finance/profit_and_loss.explore.lkml index 730c33f7..aacd9659 100644 --- a/explores_finance/profit_and_loss.explore.lkml +++ b/explores_finance/profit_and_loss.explore.lkml @@ -35,8 +35,12 @@ explore: profit_and_loss { join: profit_and_loss_03_selected_fiscal_periods_sdt { type: inner relationship: many_to_many - sql_on: ${profit_and_loss.fiscal_year} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_year} - and ${profit_and_loss.fiscal_period} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_period};; + sql_on: + ${profit_and_loss.glhierarchy} = ${profit_and_loss_03_selected_fiscal_periods_sdt.glhierarchy} AND + ${profit_and_loss.company_code} = ${profit_and_loss_03_selected_fiscal_periods_sdt.company_code} AND + ${profit_and_loss.fiscal_year} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_year} AND + ${profit_and_loss.fiscal_period} = ${profit_and_loss_03_selected_fiscal_periods_sdt.fiscal_period};; + } join: profit_and_loss_hierarchy_selection_sdt { diff --git a/views/balance_sheet_fiscal_periods_sdt.view.lkml b/views/balance_sheet_fiscal_periods_sdt.view.lkml index 870a89d6..0212f835 100644 --- a/views/balance_sheet_fiscal_periods_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_sdt.view.lkml @@ -1,21 +1,21 @@ #########################################################{ -# PURPOSE: +# PURPOSE # Finds the Fiscal Years and Periods available in Balance Sheet # And derives the following fields: # - fiscal_year_period # - yoy_fiscal_period # - prior_fiscal_year_period # -# SOURCE: +# SOURCE # Table @{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet # -# REFERENCED IN: +# REFERENCED BY # View balance_sheet_fiscal_periods_selected to identify comparison period based on user selections # -# NOTE: no dimensions or measure are defined as this view is only referenced in another view +# NOTE +# This view is only referenced in another view and does not define any dimensions or measures. #########################################################} - view: balance_sheet_fiscal_periods_sdt { derived_table: { sql: diff --git a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml index 74d166ac..431feb13 100644 --- a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml @@ -1,21 +1,21 @@ #########################################################{ -# PURPOSE: +# PURPOSE # Derives Reporting vs Comparison Periods based on user inputs # -# REFERENCED IN: -# Explore balance_sheet -# -# SOURCE: +# SOURCE # View balance_sheet_fiscal_periods_sdt # -# KEYS TO USING: +# REFERENCED BY +# Explore balance_sheet +# +# KEYS TO USING # - View label is "Reporting vs. Comparison Period" # - Fields are hidden by default so must change "hidden: property" to "no" to include in an Explore # - Measures includes references to fields from view balance_sheet so must join this view to balance_sheet using an inner join on: # hierarchy_name, company_code, fiscal_year, fiscal_period # Note, the source view already filters to a single Client id so it is not needed in the join # -# PROCESS: +# PROCESS # 1) Captures inputs from parameters: # balance_sheet.select_fiscal_period -- user selects a single "Reporting" fiscal period # balance_sheet.select_compare_to -- user can compare the Reporting period to either: same period a year ago, the prior fiscal period, a specific fiscal period @@ -28,7 +28,7 @@ # fiscal_period_group -- value of Reporting or Comparison # alignment_group_name -- equals the value of the selected reporting period # -# MEASURES: +# MEASURES # reporting_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Reporting' # comparison_period_amount_in_global_currency -- Cumulative Amount in Global Currency when fiscal_period_group = 'Comparison' # difference_value -- reporting_period_amount_in_global_currency - comparison_period_amount_in_global_currency diff --git a/views/balance_sheet_hierarchy_selection_sdt.view.lkml b/views/balance_sheet_hierarchy_selection_sdt.view.lkml index b64de05c..a9af9158 100644 --- a/views/balance_sheet_hierarchy_selection_sdt.view.lkml +++ b/views/balance_sheet_hierarchy_selection_sdt.view.lkml @@ -2,14 +2,14 @@ # PURPOSE # SQL Derived Table (SDT) to select the Node levels to display in Balance Sheet report. Assigns values to Hier1_node_text to Heir5_node_text based on user inputs. # -# SOURCES: +# SOURCES # View balance_sheet_path_to_node_pdt # Extends View common_hierarchy_fields_finance_ext # -# REFERENCED IN: +# REFERENCED BY # Explore Balance Sheet # -# PROCESS: +# PROCESS # 1) Captures inputs from parameters: # parameter_pick_start_level -- select top level of hierarchy to show # parameter_pick_depth_level -- how many levels should be shown (1 to 5 levels) @@ -22,7 +22,7 @@ # For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level. # Additionally, levels 2 and 3, where IsLeafNode equals true, will also be selected. # -# CAVEATS: +# CAVEATS # If more than 5 hierarchy levels are needed: # - update the parameter_pick_depth_level to accept additional values # - add additional hierN SQL statements @@ -36,7 +36,7 @@ # hier1_node_text ... hier5_node_text # hier1_node ... hier5_node # -# PRIMARY KEY: +# PRIMARY KEY # client_mandt # hierarchy_name # chart_of_accounts diff --git a/views/balance_sheet_navigation_ext.view.lkml b/views/balance_sheet_navigation_ext.view.lkml index 323a75d2..a9634246 100644 --- a/views/balance_sheet_navigation_ext.view.lkml +++ b/views/balance_sheet_navigation_ext.view.lkml @@ -1,35 +1,47 @@ #########################################################{ -# Extends and modifies navigation_template to support navigation between -# related Balance Sheet Subtotal Dashboards: With Comparisons and No Comparisons +# PURPOSE +# Dynamically generates html links (including filters) to supports navigation between +# related Balance Sheet Subtotal Dashboards: With Comparisons and No Comparisons. # -# One sets of LookML dashboards are included: +# SOURCE +# Extends View navigation_template +# +# REFERENCED BY +# Explore balance_sheet +# Dashboards: # - Subtotal Table With Comparisons (balance_sheet_subtotal3_table) -# and Without Comparisons (balance_sheet_subtotal3_table_no_comparison) +# - Subtotal Table Without Comparisons (balance_sheet_subtotal3_table_no_comparison) +# - Note, Marketplace dashboard handles no comparisons cleanly so no additonal dashboard needed # -# Note, Marketplace dashboard handles no comparisons cleanly so no additonal dashboard needed +# CUSTOMIZATIONS +# While the navigation_template provides much of the logic needed, customizations for Balance Sheet +# are required. +# 1. dash_bindings -- added dashboard name and link text for each dashboard +# dashboard name link text +# --------------- --------------- +# balance_sheet_subtotal3_table With Comparisons +# balance_sheet_subtotal3_table_no_comparison No Comparisons # -# Customizations: -# dash_bindings: added dashboard and link names -# filter_bindings: added 7 filters and corresponding URL values -# filter label URL format -# ------- --------------- --------------------- -# filter1 Fiscal Period Fiscal+Period -# filter2 Global Currency Global+Currency -# filter3 Hierarchy Hierarchy -# filter4 Chart of Accounts Chart+of+Accounts -# filter5 Company Company -# filter6 Ledger Name Ledger+Name -# filter7 Top Hierarchy Level Top+Hierarchy+Level +# 2. filter_bindings -- added 7 filters and corresponding URL values +# filter label URL format +# ------- --------------- --------------------- +# filter1 Fiscal Period Fiscal+Period +# filter2 Global Currency Global+Currency +# filter3 Hierarchy Hierarchy +# filter4 Chart of Accounts Chart+of+Accounts +# filter5 Company Company +# filter6 Ledger Name Ledger+Name +# filter7 Top Hierarchy Level Top+Hierarchy+Level # -# tip: to find URL formats copy url for dashboard and review list of parameters after +# tip: to find URL formats copy url for dashboard and review list of parameters after # [dashboard name]? # -# filter1 to filter7 filters: added labels as indicated above (NOTE: can optionally unhide) -# navigation_focus_page: confirmed allowed values of 1 or 2 -# added group_label = "Navigation" for parameters exposed in the Explore +# 3. filter1 to filter7 filters: added labels as indicated above (NOTE: can optionally unhide) +# 4. navigation_focus_page: confirmed allowed values of 1 or 2 +# 5. added group_label = "Navigation" for parameters exposed in the Explore # -# To use this view: -# 1) Add to an explore using a bare join +# HOW TO USE FOR NAVIGATION +# 1. Add to an Explore using a bare join # explore: balance_sheet { # join: balance_sheet_navigation_ext { # view_label: "🔍 Filters & 🛠 Tools" @@ -37,11 +49,11 @@ # sql: ;; # }} # -# 2) Add Navigation dimension to Single Value Visualization and set these paramaters accordingly -# Navigation Style = small +# 2. Add Navigation dimension to Single Value Visualization and set these paramaters accordingly +# Navigation Style = Hyperlinks - Left Aligned - No Border - Small font (or if using lookml, = small) # Navigation Focus Page = 1 (if adding to first dashboard listed, set to 2 if added viz to second dashboard) # -# 3) Add Navigation visualization to balance_sheet_subtotal_table dashboard and set viz to listen to the dashboard filters +# 3. Add Navigation visualization to dashboard and set viz to listen to the dashboard filters # # Below is example Dashboard LookML generated: # - title: navigation diff --git a/views/balance_sheet_path_to_node_pdt.view.lkml b/views/balance_sheet_path_to_node_pdt.view.lkml index bbe0f51e..5182dd82 100644 --- a/views/balance_sheet_path_to_node_pdt.view.lkml +++ b/views/balance_sheet_path_to_node_pdt.view.lkml @@ -1,9 +1,19 @@ -######################################################### -# this Persistent Derived Table (pdt) derives the full path to a node (e.g., Assets/Current Assets/Cash & Equivalents) +#########################################################{ +# PURPOSE +# This Persistent Derived Table (PDT) derives the full path to a node using RECURSIVE +# to navigate the parent-child relationships. +# For example, for Child Node Cash & Equivalents, the path is: +# Assets-->Current Assets-->Cash & Equivalents # -# Uses RECURSIVE to navigate the parent-child relationships and derive the full path -# This view is only referenced in the view balance_sheet_hierarchy_selection_sdt -######################################################### +# SOURCE +# Table `@{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet` +# +# REFERENCED BY +# View balance_sheet_hierarchy_selection_sdt +# +# UPDATE SCHEDULE +# triggered when distinct count of nodes changes (see datagroup trigger balance_sheet_node_count) +#########################################################} view: balance_sheet_path_to_node_pdt { derived_table: { @@ -108,4 +118,4 @@ view: balance_sheet_path_to_node_pdt { ;; } } -} \ No newline at end of file +} diff --git a/views/balance_sheet_rfn.view.lkml b/views/balance_sheet_rfn.view.lkml index dce136ca..86ad6a6c 100644 --- a/views/balance_sheet_rfn.view.lkml +++ b/views/balance_sheet_rfn.view.lkml @@ -1,5 +1,7 @@ #########################################################{ -# balance_sheet view reflects an aggregation of Transactions by the following dimensions: +# PURPOSE +# The BalanceSheet table and its corresponding View balance_sheet reflects +# an aggregation of Transactions by the following dimensions: # Client # Fiscal Year # Fiscal Period @@ -12,15 +14,32 @@ # Languague # Global (Target) Currency # -# Measures: +# SOURCES +# Refines View balance_sheet (defined in file balance_sheet_base.view) +# Extends View common_fields_finance_ext +# +# REFERENCED BY +# Explore balance_sheet +# +# EXTENDED FIELDS +# Extends common dimensions found in both balance sheet and profit and loss +# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, +# fiscal_period, fiscal_quarter, fiscal_year and related fields +# Make changes to these dimensions in the common_fields_finance_ext view or +# in this view if the changes are specific to the Balance Sheet. +# +# KEY MEASURES # Amount in Local Currency, Amount in Global Currency # Cumulative Amount in Local Currency, Cumulative Amount in Global Currency # Exchange Rate (based on last date in the period) # Avg Exchange Rate, Max Exchange Rate +# Current Ratio, Current Assets, and Current Liabilities # -# Derives Current Ratio, Current Assets, and Current Liabilities using English-only terms found in Node (text). -# These should be edited as necessary to use Node (code) values instead text values to accomodate other languages. +# CAVEATS +# Current Ratio and related measures are defined using English-only terms found in Node (text). +# Edit these as necessary to support other languages or use Node values instead of text. # +# HOW TO USE # To query this table, always include Fiscal Year and Fiscal Period as dimensions # and filter to: # - a single Client MANDT (handled with Constant defined in Manifest file) @@ -29,13 +48,6 @@ # - a single Hierarchy Name or Financial Statement Version # - a single Chart of Accounts # - a single Company -# -# EXTENDED FIELDS: -# Extends common dimensions found in both balance sheet and profit and loss using view common_fields_finance_ext -# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, -# fiscal_period, fiscal_quarter, fiscal_year and related fields -# Changes to these dimensions can be made in view common_fields_finance_ext if the changes are for both balance sheet and profit and loss; -# or customize these dimensions specifically for Balance Sheet in this view as needed #########################################################} @@ -86,7 +98,7 @@ view: +balance_sheet { label: "Year Ago" value: "yoy" } allowed_value: { - label: "Previous Fiscal Period" value: "prior" + label: "Prior Fiscal Period" value: "prior" } allowed_value: { label: "Custom Comparison Period" value: "custom" diff --git a/views/common_fields_finance_ext.view.lkml b/views/common_fields_finance_ext.view.lkml index 992881db..d47edac3 100644 --- a/views/common_fields_finance_ext.view.lkml +++ b/views/common_fields_finance_ext.view.lkml @@ -1,12 +1,14 @@ #########################################################{ -# common fields and parameters to be EXTENDED into: +# PURPOSE +# Defines dimensions and parameters to be EXTENDED into: # balance_sheet_rfn # profit_and_loss_rfn +# The properties from this view are used and customized by extending views. # -# This view's established properties will be utilized by any views that use this view as an extension. -# Once extended into balance_sheet_rfn and profit_and_loss_rfn, these dimensions can be customized as necessary in the extending views. +# SOURCE +# none. The ${TABLE} property uses the table definition of the extending view # -# includes: +# EXTENDABLE FIELDS # client_mandt # language_key_spras # currency_key @@ -26,6 +28,7 @@ view: common_fields_finance_ext { + extension: required dimension: client_mandt { type: string diff --git a/views/common_hierarchy_fields_finance_ext.view.lkml b/views/common_hierarchy_fields_finance_ext.view.lkml index 2d56768f..f9c9cd3c 100644 --- a/views/common_hierarchy_fields_finance_ext.view.lkml +++ b/views/common_hierarchy_fields_finance_ext.view.lkml @@ -1,10 +1,19 @@ #########################################################{ -# common hierarchy-related fields and parameters to be EXTENDED into: +# PURPOSE +# Defines hierarchy-related dimensions and parameters to be EXTENDED into: # balance_sheet_hierarchy_selection_sdt # profit_and_loss_hierarchy_selection_sdt # -# This view's established properties will be utilized by any views that use this view as an extension. +# The properties from this view are used and customized by extending views. # +# SOURCE +# none. The ${TABLE} property uses the table definition of the extending view +# +# EXTENDABLE FIELDS +# parameter_pick_start_level, parameter_pick_depth_level +# node_text_path_string, node_path_string +# hier1_node_text to hier5_node_text +# hier1_node to hier5_node (used as order by fields for hierN_node_text dimension) #########################################################} view: common_hierarchy_fields_finance_ext { diff --git a/views/fiscal_periods_sdt.view.lkml b/views/fiscal_periods_sdt.view.lkml deleted file mode 100644 index 749df213..00000000 --- a/views/fiscal_periods_sdt.view.lkml +++ /dev/null @@ -1,66 +0,0 @@ -###################### -# Finds the Fiscal Years and Periods available in Balance Sheet -# -# Used as source for Fiscal Period parameter or filter selections -# Depending on max_fp_size, fiscal_year_period will display either YYYY.PP or YYYY.PPP -# includes dimension negative_fiscal_year_period_number which: -# - is used as an order_by_field for fiscal_year_period -# - allows the fiscal_year_period to be displayed in descending order in paramter/filter drop-down selectors -###################### - -view: fiscal_periods_sdt { - derived_table: { - sql: - select - FiscalYear as fiscal_year, - FiscalPeriod as fiscal_period, - concat(b.FiscalYear,'.Q',b.FiscalQuarter) as fiscal_year_quarter, - concat(b.FiscalYear,'.',b.FiscalPeriod) AS fiscal_year_period, - parse_numeric(concat(b.FiscalYear,b.FiscalPeriod)) * -1 as negative_fiscal_year_period_number, - parse_numeric(concat(b.FiscalYear,b.FiscalQuarter)) * -1 as negative_fiscal_year_quarter_number - FROM `@{GCP_PROJECT}.@{REPORTING_DATASET}.BalanceSheet` AS b - GROUP BY - fiscal_year, - fiscal_period, - fiscal_year_quarter, - fiscal_year_period, - negative_fiscal_year_period_number, - negative_fiscal_year_quarter_number;; - } - - dimension: fiscal_year { - type: string - sql: ${TABLE}.fiscal_year ;; - } - - dimension: fiscal_period { - type: string - sql: ${TABLE}.fiscal_period ;; - } - - dimension: fiscal_year_quarter { - type: string - sql: ${TABLE}.fiscal_year_quarter ;; - } - - dimension: fiscal_year_period { - type: string - primary_key: yes - sql: ${TABLE}.fiscal_year_period ;; - order_by_field: negative_fiscal_year_period_number - } - - dimension: negative_fiscal_year_period_number { - hidden: yes - type: number - sql: ${TABLE}.negative_fiscal_year_period_number ;; - } - - dimension: negative_fiscal_year_quarter_number { - hidden: yes - type: number - sql: ${TABLE}.negative_fiscal_year_quarter_number ;; - } - - -} diff --git a/views/navigation_template.view.lkml b/views/navigation_template.view.lkml index a6b6852d..5eadcce9 100644 --- a/views/navigation_template.view.lkml +++ b/views/navigation_template.view.lkml @@ -1,40 +1,69 @@ #########################################################{ -# use this template to generate an html navigation bar, navigation tabs or simple navigation with small text -# this template can only be EXTENDED into another view +# PURPOSE +# Provides a template for dynamically creating and formatting HTML links for +# navigation between dashboards including the transfer of filter values. # -# this template provides three styles and up to 10 possible filters: -# horizontal bar with gray background and cortex image (set with parameter navigation_style = "bar") -# tabbed with cortex image (set with parameter navigation_style = "tabs") -# small text with links only and no image or formatting (set with parameter navigation_style = "small") +# SOURCE +# none (This template can only be EXTENDED into another view) # -# modify this template if you want different styles or more filters +# STYLES +# This template provides three styles for the html links. Pick which one to use +# with parameter_navigation_style +# 1. horizontal bar with gray background and cortex image +# parameter label: "Hyperlinks - Center Aligned in Box" +# parameter value: "bar" +# 2. tabbed with cortex image +# parameter label: "Tabs" +# parameter value: "tab" +# 3. small text with links only (no image or unique formatting) +# parameter label: "Hyperlinks - Left Aligned - No Border - Small font" +# parameter value: "small" # -# extend this template into a view and customize for: -# list of dashboards (ids and names) -# list of filters (filter1, filter2, etc... with label used in dashboard filters) +# To add or modify styles, edit the section in the navigation dimension # -# To extend this template: -# - create new view -# - add extend: parameter and reference this view (navigation_template) -# - required updates: -# - edit the sql: parameter of dash_bindings dimension with list of dashboard ids and names: -# for udd dashboards use numeric id: -# sql: '131|Dashboard 1||132|Dashboard 2' ;; +# FILTERS +# This template allows a dasboard to pass up to 10 possible filters. Modify this template if +# more filters are needed. Edit the sections. # -# for lookml dashboards use lookml dashboard name with or without model name: -# sql: 'dashboard_name1|Dashboard 1||dashboard_name2|Dashboard 2';; -# sql: 'model_name::dashboard_name1|Dashboard 1||model_name::dashboard_name2|Dashboard 2';; # -# - edit the sql: parameter of filter_bindings dimension with list of filters that should be passed from one dashboard to another -# sql: 'filter1|Filter 1 Name||filter2|Filter 2 Name' ;; +# STEPS TO EXTEND THIS TEMPLATE +# When you extend this template, make the REQUIRED customizations by following these steps: +# 1. create new view +# 2. add "extend: navigation_template" parameter (use name of this view) +# 3. edit dash_bindings dimension +# - Update the "sql" property to include a list of dashboard IDs and corresponding names +# (or link text) using the following pattern: +# ID1|Link1||ID2|Link2 +# - for UDD dashboards use numeric id: +# sql: '131|Dashboard 1 Link Text||132|Dashboard 2 Link Text' ;; +# - for LookML dashboards use dashboard name with or without model name: +# sql: 'dashboard_name1|Dashboard 1||dashboard_name2|Dashboard 2';; +# sql: 'model_name::dashboard_name1|Dashboard 1||model_name::dashboard_name2|Dashboard 2';; # -# - edit filter1 to filterN (up to 10) to unhide and label +# 4. edit filter_bindings dimension +# add list of filters that should be passed from one dashboard to another +# sql: 'filter1|Filter 1 Name||filter2|Filter 2 Name' ;; # -# - optional updates: -# - change item_delimiter (||) and value_delimiter (|) to match delimiters used in Bindings dimensions +# 5. edit filter1 to filterN (up to 10) dimensions to unhide and label # -# Once this template is extended and filter1 to filter8 are labeled, create a Single Value Visualization -# and add to a dashboard. LookML example: +# 6. update parameter_tab_focus with allowed values to match the number of dashboards +# +# USING IN A DASHBOARD +# 1. Once the extending view has been created, modified, add to an Explore using a bare join: +# explore: balance_sheet { +# join: balance_sheet_navigation_ext { +# view_label: "🔍 Filters & 🛠 Tools" +# relationship: one_to_one +# sql: ;; +# }} +# 2. Open the Explore and add "navigation" dimension to a Single Value Visualization +# 3. Add the navigation parameters as filters and set to desired values +# navigation_style = "Hyperlinks - Left Aligned - No Border - Small font" +# navigation_tab_focus = 1 for Dashboard 1. Set to 2 for Dashboard 2 and so on +# 4. Add Visualization to each of the dashboards and map dashboard filters to pass values +# to Filters 1 to N accordingly +# +# LookML example of the dashboard element is below: # - title: navigation # name: navigation # explore: profit_and_loss @@ -74,8 +103,9 @@ view: navigation_template { sql: 'filter1|Filter 1 Name||filter1|Filter 2 Name' ;; } +# # ** override hidden and label in extension as required ** - # ** Add more as required, currently supports 5 ** + # ** Add more as required, currently supports 10 ** filter: filter1 { hidden: yes label: "filter1"} filter: filter2 { hidden: yes label: "filter2"} filter: filter3 { hidden: yes label: "filter3"} @@ -103,6 +133,7 @@ view: navigation_template { sql: '|' ;; } +# # use parameter to choose navigation style parameter: navigation_style { hidden: no @@ -114,7 +145,6 @@ view: navigation_template { default_value: "tabs" } - # use parameter to set focus page until bug with _explore._dashboard_url is fixed # update allowed values to match number of dashboards defined in extension parameter: navigation_focus_page { @@ -147,30 +177,31 @@ view: navigation_template { {% assign queryString = "" %} {% assign modelName = _model._name %} + {% case navStyle %} {% when "bar" %} - {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} - {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 20px;" %} - {% assign divStyle = "border-radius: 5px; padding-top: 6px; padding-bottom: 20px; height: 60px; background: #F5F5F5;" %} - {% assign spanStyle = "font-size: 18px; display: table; margin:0 auto;" %} - {% assign imgStyle = "float: left; vertical-align: middle; height: 45px;" %} - {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} + {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} + {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 20px;" %} + {% assign divStyle = "border-radius: 5px; padding-top: 6px; padding-bottom: 20px; height: 60px; background: #F5F5F5;" %} + {% assign spanStyle = "font-size: 18px; display: table; margin:0 auto;" %} + {% assign imgStyle = "float: left; vertical-align: middle; height: 45px;" %} + {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} {% when "tabs" %} - {% assign sharedStyle = "font-color: #4285F4; padding: 5px 15px; border-style: solid; border-radius: 5px 5px 0 0; float: left; line-height: 20px; "%} - {% assign linkStyle = sharedStyle | append: "border-width: 1px; border-color: #D3D3D3;" %} - {% assign currentPageLinkStyle = sharedStyle | append: "border-width: 2px; border-color: #808080 #808080 #F5F5F5 #808080; font-weight: bold; background-color: #F5F5F5;" %} - {% assign divStyle = "border-bottom: solid 2px #808080; padding: 6px 10px 5px 10px; height: 40px;" %} - {% assign spanStyle = "font-size: 16px; padding: 6px 10px 0 10px; height: 40px;" %} - {% assign imgStyle = "float: left; vertical-align: middle; height: 39px;" %} - {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} + {% assign sharedStyle = "font-color: #4285F4; padding: 5px 15px; border-style: solid; border-radius: 5px 5px 0 0; float: left; line-height: 20px; "%} + {% assign linkStyle = sharedStyle | append: "border-width: 1px; border-color: #D3D3D3;" %} + {% assign currentPageLinkStyle = sharedStyle | append: "border-width: 2px; border-color: #808080 #808080 #F5F5F5 #808080; font-weight: bold; background-color: #F5F5F5;" %} + {% assign divStyle = "border-bottom: solid 2px #808080; padding: 6px 10px 5px 10px; height: 40px;" %} + {% assign spanStyle = "font-size: 16px; padding: 6px 10px 0 10px; height: 40px;" %} + {% assign imgStyle = "float: left; vertical-align: middle; height: 39px;" %} + {% assign imgSrc = "https://marketplace-api.looker.com/block-icons/cortex_icon.png" %} {% when "small" %} - {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} - {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 12px;" %} - {% assign divStyle = "float: left;" %} - {% assign spanStyle = "font-size: 10px; display: table; margin:0 auto;" %} - {% assign imgStyle = "" %} - {% assign imgSrc = "" %} + {% assign linkStyle = "color: #0059D6; padding: 5px 15px; float: left; line-height: 40px;" %} + {% assign currentPageLinkStyle = linkStyle | append: "font-weight:bold;font-size: 12px;" %} + {% assign divStyle = "float: left;" %} + {% assign spanStyle = "font-size: 10px; display: table; margin:0 auto;" %} + {% assign imgStyle = "" %} + {% assign imgSrc = "" %} {% endcase %} @@ -181,33 +212,34 @@ view: navigation_template { {% assign filterField = filterParts[0] %} {% assign filterName = filterParts[1] %} + - + {% case filterField %} - {% when "filter1" %} - {% assign filterValue = _filters['filter1'] | url_encode %} - {% when "filter2" %} - {% assign filterValue = _filters['filter2'] | url_encode %} - {% when "filter3" %} - {% assign filterValue = _filters['filter3'] | url_encode %} - {% when "filter4" %} - {% assign filterValue = _filters['filter4'] | url_encode %} - {% when "filter5" %} - {% assign filterValue = _filters['filter5'] | url_encode %} - {% when "filter6" %} - {% assign filterValue = _filters['filter6'] | url_encode %} - {% when "filter7" %} - {% assign filterValue = _filters['filter7'] | url_encode %} - {% when "filter8" %} - {% assign filterValue = _filters['filter8'] | url_encode %} - {% when "filter9" %} - {% assign filterValue = _filters['filter9'] | url_encode %} - {% when "filter10" %} - {% assign filterValue = _filters['filter10'] | url_encode %} + {% when "filter1" %} + {% assign filterValue = _filters['filter1'] | url_encode %} + {% when "filter2" %} + {% assign filterValue = _filters['filter2'] | url_encode %} + {% when "filter3" %} + {% assign filterValue = _filters['filter3'] | url_encode %} + {% when "filter4" %} + {% assign filterValue = _filters['filter4'] | url_encode %} + {% when "filter5" %} + {% assign filterValue = _filters['filter5'] | url_encode %} + {% when "filter6" %} + {% assign filterValue = _filters['filter6'] | url_encode %} + {% when "filter7" %} + {% assign filterValue = _filters['filter7'] | url_encode %} + {% when "filter8" %} + {% assign filterValue = _filters['filter8'] | url_encode %} + {% when "filter9" %} + {% assign filterValue = _filters['filter9'] | url_encode %} + {% when "filter10" %} + {% assign filterValue = _filters['filter10'] | url_encode %} {% else %} - {% assign filterValue = "out of range filter" %} - + {% assign filterValue = "out of range filter" %} + {% endcase %} @@ -227,21 +259,21 @@ view: navigation_template { {% for navItem in navItems %} - {% assign navParts = navItem | split: value_delimiter._value %} - {% assign dashName = navParts[1] %} - {% assign dashID = navParts[0] %} - {% assign dashIDcheckType = dashID | plus: 0 %} + {% assign navParts = navItem | split: value_delimiter._value %} + {% assign dashName = navParts[1] %} + {% assign dashID = navParts[0] %} + {% assign dashIDcheckType = dashID | plus: 0 %} {% if dashIDcheckType == 0 %} - - {% if dashID contains '::' %} - {% else %} - {% assign dashID = modelName | append: '::' | append: dashID %} - {% endif %} + + {% if dashID contains '::' %} + {% else %} + {% assign dashID = modelName | append: '::' | append: dashID %} + {% endif %} {% endif %} @@ -250,11 +282,11 @@ view: navigation_template { {% if navigation_focus_page._in_query and counter == focus %} - {{ dashName }} + {{ dashName }} {% elsif _explore._dashboard_url == dashUrl %} - {{ dashName }} + {{ dashName }} {% else %} - {{ dashName }} + {{ dashName }} {% endif %} diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index a8d59824..d1e3706d 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -204,8 +204,8 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { dimension: alignment_group { type: number - hidden: yes - sql: ${TABLE}.alignment_group ;; + hidden: no + sql: UPPER(CAST(${TABLE}.alignment_group as STRING)) ;; } dimension: alignment_group_name { diff --git a/views/profit_and_loss_rfn.view.lkml b/views/profit_and_loss_rfn.view.lkml index 3ae8ed6e..f747739b 100644 --- a/views/profit_and_loss_rfn.view.lkml +++ b/views/profit_and_loss_rfn.view.lkml @@ -111,7 +111,7 @@ view: +profit_and_loss { label: "Year Ago" value: "yoy" } allowed_value: { - label: "Previous Fiscal Timeframe" value: "prior" + label: "Prior Fiscal Timeframe" value: "prior" } default_value: "none" } From 1d3784610caaba4b69a3dae92071cfec2fcb666d Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Mon, 25 Mar 2024 16:27:44 +0000 Subject: [PATCH 11/16] profit_and_loss: update company filter to be required in dashboard; update comments --- ...income_statement_template.dashboard.lookml | 2 +- ..._01_reporting_fiscal_periods_sdt.view.lkml | 37 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/LookML_Dashboard/income_statement_template.dashboard.lookml b/LookML_Dashboard/income_statement_template.dashboard.lookml index 13cabcf5..1af5e3b4 100644 --- a/LookML_Dashboard/income_statement_template.dashboard.lookml +++ b/LookML_Dashboard/income_statement_template.dashboard.lookml @@ -183,7 +183,7 @@ type: field_filter default_value: "%CENTRAL%" allow_multiple_values: false - required: false + required: true ui_config: type: dropdown_menu display: inline diff --git a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml index a42a59ae..da52fbc0 100644 --- a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml @@ -1,22 +1,30 @@ #########################################################{ +# PURPOSE # Step 1 of 3 in deriving Reporting and Comparison Groups of timeframes -# Step 1 - Derive Reporting selection -# This SQL Derived Table (sdt) uses view profit_and_loss_fiscal_periods_sdt as source and: -# 1) Takes user inputs from parameters and filters: -# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report -# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison -# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Group else each timeframe selected will be displayed in report -# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report # -# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters -# and filters to return the "Reporting" timeframe selected +# SOURCE +# View profit_and_loss_fiscal_periods_sdt +# +# REFERENCED BY +# VIEW profit_and_loss_02_comparison_fiscal_periods_sdt +# VIEW profit_and_loss_03_selected_fiscal_periods_sdt +# +# PROCESS FOR STEP 1 - DERIVE REPORTING SELECTION +# 1) Captures user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension -- filter and display either Fiscal Year, Fiscal Quarter or Fiscal Period +# profit_and_loss.parameter_compare_to -- compare selected reporting timeframe to either same timeframe last year, the prior timeframe or no comparison +# profit_and_loss.parameter_aggregate -- If "yes" is selected, all selected timeframes will be combined into a single Reporting/Comparison Group. Otherwise, each selected timeframe will be displayed separately in the report. +# profit_and_loss.filter_fiscal_timeframe -- select one or more fiscal timeframes (either Year, Quarter or Fiscal Period) to include in Income Statement report +# +# 2) Builds SQL statement based on parameter values selected. Returns the fiscal periods +# representing the "Reporting" group. # # 3) Derives new dimensions: -# fiscal_reporting_group -- value of Reporting +# fiscal_reporting_group -- value of "Reporting" # alignment_group -- if parameter_aggregate = 'Yes' assign 1 else -# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. If multiple timeframes selected, each set of comparisons will be given a unique group number +# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. # -# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number +# If multiple timeframes selected and Aggregate = 'No', each set comparisons will be given a unique group number # e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: # alignment group 1 = 2024.001 compared to 2023.001 # alignment group 2 = 2024.002 compared to 2023.002 @@ -25,7 +33,7 @@ # e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: # alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 # -# selected_timeframe -- returns either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension +# selected_timeframe -- returns values for either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension # timeframe_join -- added if parameter_compare_to != 'none'; used in Step 2 to join between reporting and profit_and_loss_fiscal_periods_sdt to derive comparison periods # -- if parameter_compare_to = 'yoy' then fiscal_year_period # else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then use the [timeframe]_rank for the selected timeframe @@ -44,9 +52,6 @@ include: "/views/profit_and_loss_fiscal_periods_sdt.view" view: profit_and_loss_01_reporting_fiscal_periods_sdt { - extends: [profit_and_loss_fiscal_periods_sdt] - - fields_hidden_by_default: no derived_table: { sql: From bd84ceb06447f08a33a4aeb2c636d798d1c32d15 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Mon, 25 Mar 2024 18:13:53 +0000 Subject: [PATCH 12/16] profit_and_loss: modified to allow multiple companies to be selected --- ...income_statement_template.dashboard.lookml | 6 ++--- ..._01_reporting_fiscal_periods_sdt.view.lkml | 2 +- ...02_comparison_fiscal_periods_sdt.view.lkml | 23 ++++++++++--------- ...s_03_selected_fiscal_periods_sdt.view.lkml | 7 ++++-- views/profit_and_loss_rfn.view.lkml | 5 ++-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/LookML_Dashboard/income_statement_template.dashboard.lookml b/LookML_Dashboard/income_statement_template.dashboard.lookml index 1af5e3b4..77a45226 100644 --- a/LookML_Dashboard/income_statement_template.dashboard.lookml +++ b/LookML_Dashboard/income_statement_template.dashboard.lookml @@ -182,10 +182,10 @@ title: Company type: field_filter default_value: "%CENTRAL%" - allow_multiple_values: false - required: true + allow_multiple_values: true + required: false ui_config: - type: dropdown_menu + type: tag_list display: inline explore: profit_and_loss listens_to_filters: [] diff --git a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml index da52fbc0..68ac5d85 100644 --- a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml @@ -79,7 +79,7 @@ view: profit_and_loss_01_reporting_fiscal_periods_sdt { {% endif %} {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} - {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (window_pk ORDER BY " | append: timeframe_field | append: " DESC)" %} + {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (ORDER BY " | append: timeframe_field | append: " DESC)" %} {% endif %} diff --git a/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml index e3b1656d..90afee49 100644 --- a/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml @@ -80,7 +80,7 @@ view: profit_and_loss_02_comparison_fiscal_periods_sdt { {% assign rank_field = timeframe_field | append: "_rank" %} {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} - {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (window_pk ORDER BY comp." | append: timeframe_field | append: " DESC)" %} + {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (ORDER BY comp." | append: timeframe_field | append: " DESC)" %} {% endif %} {% if comparison_type == 'yoy' %}{% assign timeframe_join_sql = "fiscal_year_period" %} @@ -92,16 +92,17 @@ view: profit_and_loss_02_comparison_fiscal_periods_sdt { {% assign join1_sql = "AND rep.prior_timeframe_join = comp." | append: timeframe_join_sql %} - SELECT comp.glhierarchy, - comp.company_code, - comp.fiscal_year_period, - comp.fiscal_year_quarter, - comp.fiscal_year, - comp.fiscal_period, - {{alignment_group_sql}} AS alignment_group, - comp.{{timeframe_field}} AS selected_timeframe, - rep.is_partial_timeframe, - 'Comparison' AS fiscal_reporting_group + SELECT + comp.glhierarchy, + comp.company_code, + comp.fiscal_year_period, + comp.fiscal_year_quarter, + comp.fiscal_year, + comp.fiscal_period, + {{alignment_group_sql}} AS alignment_group, + comp.{{timeframe_field}} AS selected_timeframe, + rep.is_partial_timeframe, + 'Comparison' AS fiscal_reporting_group FROM ${profit_and_loss_01_reporting_fiscal_periods_sdt.SQL_TABLE_NAME} rep JOIN ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} comp ON rep.glhierarchy = comp.glhierarchy diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index d1e3706d..ce788457 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -61,7 +61,7 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { {% assign tp_list = _filters['profit_and_loss.filter_fiscal_timeframe'] | sql_quote | remove: '"' | remove: "'" | replace: ",",", " | split: ", " %} {% assign tp_list = tp_list | sort | join: ", " %} {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} - {% assign window_alignment = "(PARTITION BY glhierarchy, company_code, alignment_group)" %} + {% assign window_alignment = "(PARTITION BY glhierarchy, alignment_group)" %} {% if time_level == "f" %}{% assign time_level_sql = "Fiscal Year Period"%}{%elsif time_level == "q"%}{% assign time_level_sql = "Fiscal Quarter"%}{%elsif time_level == "y" %}{% assign time_level_sql = "Fiscal Year"%}{% else %}{% assign time_level_sql = "None"%}{%endif%} {% if aggregate == 'Yes' %}{% assign alignment_group_name_sql = "'" | append: tp_list | append: "'" %} {% else %}{% assign alignment_group_name_sql = "MAX(selected_timeframe) OVER (window_alignment)" %} @@ -343,6 +343,7 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { sql: MAX(CASE WHEN ${fiscal_reporting_group} = 'Comparison' THEN ${fiscal_period} END) ;; } + # used in Income Statement dashboard; add to a single-value visualization measure: title_income_statement { type: number @@ -350,9 +351,11 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { hidden: no sql: 1 ;; html: + {% if profit_and_loss.company_text._is_filtered %}{% assign company_list = profit_and_loss.list_companies._value | replace: '|RECORD|',', ' %} + {% else %}{% assign company_list = 'All Companies' %}{%endif%}
Income Statement
- {{profit_and_loss.company_text._value}}
+ {{company_list}}
Reporting Fiscal Timeframe: {{reporting_timeframes_list_with_partial_indicator._value}}    Net Income: {{profit_and_loss.net_income._rendered_value}}M
Amounts in {{profit_and_loss.target_currency_tcurr}} diff --git a/views/profit_and_loss_rfn.view.lkml b/views/profit_and_loss_rfn.view.lkml index f747739b..9994256d 100644 --- a/views/profit_and_loss_rfn.view.lkml +++ b/views/profit_and_loss_rfn.view.lkml @@ -314,9 +314,10 @@ view: +profit_and_loss { value_format_name: millions_d1 } - measure: list_fiscal_periods { + measure: list_companies { type: list - list_field: fiscal_year_period + hidden: yes + list_field: company_text } #} end measures From 5200b5e2b80905e0838a5dedcd3f01d7b8dc0f14 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 27 Mar 2024 14:26:39 +0000 Subject: [PATCH 13/16] Updates for README, RELEASE_NOTES and comments for views and explores --- README.md | 46 +++--- RELEASE_NOTES.md | 23 ++- explores_finance/balance_sheet.explore.lkml | 22 +++ explores_finance/profit_and_loss.explore.lkml | 24 +++ ...balance_sheet_fiscal_periods_sdt.view.lkml | 2 +- ...heet_fiscal_periods_selected_sdt.view.lkml | 6 +- views/language_map_sdt.view.lkml | 58 ++++--- ..._01_reporting_fiscal_periods_sdt.view.lkml | 79 +++++----- ...02_comparison_fiscal_periods_sdt.view.lkml | 147 +++++++++--------- ...s_03_selected_fiscal_periods_sdt.view.lkml | 99 +++++------- ...ofit_and_loss_fiscal_periods_sdt.view.lkml | 27 ++-- ...and_loss_hierarchy_selection_sdt.view.lkml | 50 ++++-- .../profit_and_loss_navigation_ext.view.lkml | 80 ++++++---- ...profit_and_loss_path_to_node_pdt.view.lkml | 16 +- views/profit_and_loss_rfn.view.lkml | 28 ++-- views/universal_ledgers_md_rfn.view.lkml | 21 +++ 16 files changed, 433 insertions(+), 295 deletions(-) diff --git a/README.md b/README.md index 6d0a1ed0..a81c309f 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ Gain faster insights into your Order to Cash, Finance, and Inventory data with t - **Accounts Payable** - Find financial information such as accounts payable, accounts payable turnover, overdue payables, accounts payable aging, and cash discount utilization. - **Vendor Performance** - Analyze vendor performance including delivery, lead time, price variance, purchase order status. - **Spend Analysis** - Review Key Performance Indicators (KPIs) like total spend, active vendor count and cleared invoices. Breakdown spend by purchase organization, purchase group, vendor country, and material type. +- **Balance Sheet** - View the balance sheet as of a selected fiscal period. Compare it to the same period last year, the previous fiscal period, or a different fiscal period. And display multiple levels of the selected hierarchy for a user-specified chart of accounts and company. Two dashboards using different table styles are included. +⚠️ Since [Google Cloud Cortex Framework 5.3](https://github.com/GoogleCloudPlatform/cortex-data-foundation). +- **Income Statement** - View the income statement for selected fiscal periods, individually or combined. Compare the timeframe to the same timeframe a year ago or the preceding fiscal timeframe, and display multiple levels of the GL Account hierarchy. Two dashboards using different table styles are included. +⚠️ Since [Google Cloud Cortex Framework 5.4](https://github.com/GoogleCloudPlatform/cortex-data-foundation).

Inventory

@@ -33,28 +37,6 @@ Gain faster insights into your Order to Cash, Finance, and Inventory data with t * Obsolete Inventory Value * Slow Moving Inventory Value -

Balance Sheet

- -> ⚠️ available beginning with [Google Cloud Cortex Framework 5.3](https://github.com/GoogleCloudPlatform/cortex-data-foundation). - -View the balance sheet as of a selected fiscal period, compared to the same period last year, the previous fiscal period, or a different fiscal period. And display 3-levels of the selected hierarchy for a user-specified chart of accounts and company. Two dashboards using different table styles are included. - - -- **Balance Sheet Marketplace Report** - This report uses an easy-to-read table style designed for finance reports. To use this dashboard, a Looker Admin must install the [Report Table](https://marketplace.looker.com/marketplace/detail/viz-report_table) plug-in/visualization type from Looker Marketplace. Refer to Looker documentation for [Using Looker Marketplace](https://cloud.google.com/looker/docs/marketplace). - -- **Balance Sheet Subtotals Report** - This report uses Looker's built-in table visualization with subtotals (no special installation required). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons. - -

Income Statement

- -> ⚠️ available beginning with [Google Cloud Cortex Framework 5.4](https://github.com/GoogleCloudPlatform/cortex-data-foundation). - -View the income statement for select fiscal periods (individually or combined). Compare timeframe to the same timeframe a year ago or the previous fiscal timeframe. And display 3-levels of the selected hierarchy for a company. Two set dashboards using different table styles and including/excluding comparisons are provided. - - -- **Income Statement Marketplace Report** - This report uses an easy-to-read table style designed for finance reports. To use this dashboard, a Looker Admin must install the [Report Table](https://marketplace.looker.com/marketplace/detail/viz-report_table) plug-in/visualization type from Looker Marketplace. Refer to Looker documentation for [Using Looker Marketplace](https://cloud.google.com/looker/docs/marketplace). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons. - -- **Income Statement Subtotals Report** - This report uses Looker's built-in table visualization with subtotals (no special installation required). For cleaner formatting and display, this dashboard also includes navigation option to display a report with or without comparisons. -

Required Data

@@ -95,32 +77,40 @@ With the Looker project based on your forked repository, you can customize the L

Required User Attributes

-Dashboards require four Looker [user attributes](https://cloud.google.com/looker/docs/admin-panel-users-user-attributes) to work properly. +Dashboards require several Looker [user attributes](https://cloud.google.com/looker/docs/admin-panel-users-user-attributes) to work properly. A Looker Admin should create the following user attributes and set their default values. > ⚠️ Name each user attribute exactly as listed below: | **Required User Attribute Name** | **Label** | **Data Type** | **User Access** | **Hide Value** | **Default Value** | |----------------------------------|--------------------------------------|---------------|-----------------|----------------|-------------------| +| locale | locale | String | View | No | en | | default_value_currency_required | SAP Default Currency to Display | String | Edit | No | `USD` or _desired currency like EUR, CAD or JPY_ | | client_id_rep | SAP Client Id (mandt) for Reporting | String | Edit | No | Enter your _SAP Client ID_ or `100` if using the provided test data | | sap_use_demo_data | SAP: Use Demo Data (Yes or No) | String | Edit | No | Enter `Yes` if using the provided test data. Otherwise, enter `No` | | sap_sql_flavor | SAP: SQL Flavor (ECC or S4) | String | View | No | Enter `ECC` or `S4` as required for your SAP system | -Each dashboard user can personalize these values by following these [instructions](https://cloud.google.com/looker/docs/user-account). +Each dashboard user can personalize the values of the editable user attributes by following these [instructions](https://cloud.google.com/looker/docs/user-account). +

Language

+SAP Explores filter language based on user's [locale](https://cloud.google.com/looker/docs/model-localization#assigning_users_to_a_locale) or use English as a fallback if no locale value is found. The Balance Sheet and Income Statement Explores further restrict the locale to those also found in the source tables, using English if there are no matches. -

Other Considerations

+

Report Table Visualization from Marketplace

+The Balance Sheet and Income Statement dashboards come in two different styles: +1. Looker's Table Visualization with subtotals +2. Report Table Visualization from Looker Marketplace + +The Report Table provides an easy-to-read table style designed especially for finance reports. A Looker Admin must install the visualization from marketplace to use this table style. Refer to Looker documentation for [Using Looker Marketplace](https://cloud.google.com/looker/docs/marketplace). -- **Persistent Derived Tables**: Required for using Balance Sheet dasbhoards. And if using this block with production data, you may want to convert some derived tables to [Persistent Derived Tables (PDTs)](https://cloud.google.com/looker/docs/derived-tables#use_cases_for_pdts) to improve query performance. Ensure your BigQuery Connection has enabled PDTs, then update any derived table syntax with the desired [persistence strategy](https://cloud.google.com/looker/docs/derived-tables#persistence_strategies). +

Other Considerations

-- **Locale**: The Looker user [locale](https://cloud.google.com/looker/docs/model-localization#assigning_users_to_a_locale) setting (as seen in account profile) maps to SAP language code for _BalanceSheet_, _Materials_MD_, _Vendor Performance_, and _Inventory Metrics Overview_ views and determines material text language. See [language_map](views/language_map.view.lkml) for details. +- **Persistent Derived Tables**: Required for using Balance Sheet dashboards. And if using this block with production data, you may want to convert some derived tables to [Persistent Derived Tables (PDTs)](https://cloud.google.com/looker/docs/derived-tables#use_cases_for_pdts) to improve query performance. Ensure your BigQuery Connection has enabled PDTs, then update any derived table syntax with the desired [persistence strategy](https://cloud.google.com/looker/docs/derived-tables#persistence_strategies). - **BI Engine Optimization**: Some calculations perform better with [BI Engine Optimization](https://cloud.google.com/blog/products/data-analytics/faster-queries-with-bigquery-bi-engine) enabled in BigQuery. - **Liquid Templating Language**: Some constants, views, explores and dashboard use liquid templating language. For more information, see Looker's [Liquid Variable Reference](https://cloud.google.com/looker/docs/liquid-variable-reference) documentation. -- **(Optional) Unhide additional dimensions and measures**: Many dimensions and measures are hidden for simplicity. If you find anything valuable missing, update the field's `hidden` parameter value **No** in the relevant views. +- **(Optional) Unhide additional dimensions and measures**: Many dimensions and measures are hidden for simplicity. If you find anything valuable missing, update the field's `hidden` property value to **no** in the relevant views.

Additional Resources

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 07930124..11cc2dd7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,15 +1,22 @@ ## Release v5.4 +* General: + * Added a required constant to provide flexibility in how revenue amounts appear in Income Statement reporting. To display revenue as positive, set the value of `SIGN_CHANGE` constant to `yes`. + * Removed optional constants max_fiscal_period and derive_comparison_period. + * Updated `language_map_sdt` view to default to English if no locale match or locale language does not exist in BalanceSheet or ProfitAndLoss tables. + * Added `universal_ledgers_md` view to provide Ledger Name for reporting. + * Balance Sheet: - * Improved fields descriptions and organization within the Balance Sheet Explore - * Updated underlying logic for hierarchy levels to display the selected top level and its subordinate levels, rather than just the lowest level - * Added navigation to Subtotals dashboards with and without comparisons to year ago, prior fiscal period or custom period - * Updated underlying logic for deriving comparison period to eliminate reliance on `max_fiscal_period` constant - * Added context to view definitions with more-detailed comments - * Added Balance Sheet dashboard template to minimize edits to filters and other shared elements + * Improved fields descriptions and organization within the Balance Sheet Explore. + * Updated underlying logic for hierarchy levels to display the selected top level and its subordinate levels, rather than just the lowest level. + * Added navigation feature that allows users to switch between Subtotals dashboards that provide comparisons to other timeframes and those that do not have such comparisons. + * Modified the logic behind calculating the comparison period to no longer rely on the max_fiscal_period constant. + * Added context to view and explore definitions with more-detailed comments. + * Added Balance Sheet dashboard template to minimize edits to filters and other shared dashboard elements. + * For Report Table dashboard, changed column order so that variance values appear at the end. + * Change labels used in Comparison Type parameter to `Year Ago` and `Prior Fiscal Period`. * Profit and Loss / Income Statement: - * Added views, explores and dashboards to support `Income Statement` reporting - * Added a required constant to provide flexibility in how revenue amounts appear in reporting. To display revenue as positive, set the value of `SIGN_CHANGE` constant to `yes` + * Added views, explores and dashboards to support `Income Statement` reporting. ## Release v5.3.1 * Balance Sheet Updates: diff --git a/explores_finance/balance_sheet.explore.lkml b/explores_finance/balance_sheet.explore.lkml index 66793b7f..eeb4717a 100644 --- a/explores_finance/balance_sheet.explore.lkml +++ b/explores_finance/balance_sheet.explore.lkml @@ -1,3 +1,25 @@ +#########################################################{ +# PURPOSE +# The Balance Sheet Explore supports the Balance Sheet dashboards +# and any adhoc querying of balance_sheet +# +# SOURCES +# See the "include: " statements below for specifc source +# +# REFERENCED BY +# LookML dashboards: +# balance_sheet_template +# balance_sheet_mktplace_report_table +# balance_sheet_subtotal3_table +# balance_sheet_subtotal3_table_no_comparison +# +# KEYS TO USING +# - always_filter on hierarchy_name, chart_of_accounts, company_text and target_currency_tcurr +# - always_join to `language_map_sdt` so Explore automatically filters to user's locale setting (or English) +# - sql_always_where to limit to single Client MANDT based on CLIENT constant set in manifest file +# - For small views that only add a few fields to the Explore, set the view label to "Balance Sheet" in the "join:" property. +#########################################################} + include: "/views/balance_sheet_rfn.view" include: "/views/language_map_sdt.view" include: "/views/universal_ledgers_md_rfn.view" diff --git a/explores_finance/profit_and_loss.explore.lkml b/explores_finance/profit_and_loss.explore.lkml index aacd9659..fc6fa522 100644 --- a/explores_finance/profit_and_loss.explore.lkml +++ b/explores_finance/profit_and_loss.explore.lkml @@ -1,3 +1,27 @@ +#########################################################{ +# PURPOSE +# The profit_and_loss Explore supports the Income Statement dashboards +# and any adhoc querying of profit_and_loss view +# +# SOURCES +# See the "include: " statements below for specifc sources +# +# REFERENCED BY +# LookML dashboards: +# income_statement_template +# income_statement_mktplace_report_table +# income_statement_mktplace_report_table_no_comparison +# income_statement_subtotal_table +# income_statement_subtotal_table_no_comparison +# +# KEYS TO USING +# - Explore and base view labeled Income Statement (instead of Profit and Loss) +# - always_filter on glhierarchy, company_text and target_currency_tcurr +# - always_join to `language_map_sdt` so Explore automatically filters to user's locale setting (or English) +# - sql_always_where to limit to single Client MANDT based on CLIENT constant set in manifest file +# - For small views that only add a few fields to the Explore, set the view label to "Balance Sheet" in the "join:" property. +#########################################################} + include: "/views/profit_and_loss_rfn.view" include: "/views/language_map_sdt.view" include: "/views/universal_ledgers_md_rfn.view" diff --git a/views/balance_sheet_fiscal_periods_sdt.view.lkml b/views/balance_sheet_fiscal_periods_sdt.view.lkml index 0212f835..3ed329d1 100644 --- a/views/balance_sheet_fiscal_periods_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_sdt.view.lkml @@ -3,7 +3,7 @@ # Finds the Fiscal Years and Periods available in Balance Sheet # And derives the following fields: # - fiscal_year_period -# - yoy_fiscal_period +# - yoy_fiscal_year_period # - prior_fiscal_year_period # # SOURCE diff --git a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml index 431feb13..2021aa2a 100644 --- a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml @@ -10,8 +10,8 @@ # # KEYS TO USING # - View label is "Reporting vs. Comparison Period" -# - Fields are hidden by default so must change "hidden: property" to "no" to include in an Explore -# - Measures includes references to fields from view balance_sheet so must join this view to balance_sheet using an inner join on: +# - Fields are hidden by default so must change field's "hidden:" property to "no" to include in an Explore +# - Measures include references to fields from view balance_sheet so must join this view to balance_sheet using an inner join on: # hierarchy_name, company_code, fiscal_year, fiscal_period # Note, the source view already filters to a single Client id so it is not needed in the join # @@ -20,7 +20,7 @@ # balance_sheet.select_fiscal_period -- user selects a single "Reporting" fiscal period # balance_sheet.select_compare_to -- user can compare the Reporting period to either: same period a year ago, the prior fiscal period, a specific fiscal period # balance_sheet.select_custom_comparison_period -- if "Custom" comparison selected, user must select one "Comparison" fiscal period. Year ago used if no period provided - +# # 2) Builds SQL statement based on parameter values selected. Returns the fiscal periods # representing the "Reporting" and "Comparison" periods # diff --git a/views/language_map_sdt.view.lkml b/views/language_map_sdt.view.lkml index a726238d..38a20b05 100644 --- a/views/language_map_sdt.view.lkml +++ b/views/language_map_sdt.view.lkml @@ -1,36 +1,56 @@ #########################################################{ -# Filters Languages_T002 to single row based on the `locale` user attribute value. -# If user does not have a locale value or if the user's locale is not one of the -# Languages used for Balance Sheet or Profit and Loss, +# PURPOSE +# This SQL-derived Table (SDT) filters Languages_T002 to single row +# based on the `locale` user attribute value. # -# The `locale` user attribute is used to Localize a LookML Model and impacts -# language used for User Interface, labels and/or number formatting. -# The supported user-interface languages with the Looker Locale Code are found here: +# ENGLISH IS DEFAULT +# English is used if the user's locale value does not match SAP locales. +# Additional checks are performed in Explores balance_sheet and profit_and_loss +# to match the user's locale with languagues in the underlying tables. +# If no match is found, English is used. +# +# SOURCE +# Table `@{GCP_PROJECT}.@{REPORTING_DATASET}.Languages_T002` +# +# REFERENCED BY +# Explore balance_sheet +# Explore profit_and_loss +# +# LOCALE USER ATTRIBUTE +# The `locale` user attribute localizes a LookML model, affecting UI language, +# labels and/or number formatting. Link to supported user-interface languages with +# Looker Locale Codes is below: # https://cloud.google.com/looker/docs/supported-user-interface-languages#localizing_the_looker_user_interface # -# If Looker has not been configured for Localization, admin will need to add -# a user_attribute named `locale` with default value of 'en' or 'EN'. -# And admin will need to assign users or user groups values using: -# Looker Locale Code or -# SAP LAISO code (two-character SAP language Code) +# If Localization is not configured in Looker, an administrator needs to add a user +# attribute named `locale` with a default value of `en` or `EN`. Then the administrator +# should assign users or user groups values using the Looker Locale Code or +# SAP LAISO code (two-character SAP language code). # -# Steps in the dynamic generation of SQL based on user's locale -# (for this example, user's locale = 'es_ES'): -# 1. Capture user's value in locale user attribute and: +# PROCESS +# Below are the steps take to dynamically generate SQL base on user's locale. +# For this example, we'll assume the user's locale is 'es_ES'. +# 1) Capture user's value in locale user attribute and: # - replace 'nb' with 'no' (so Norweign locale string parse correctly to SAP LAISO code) # - convert to UPPER case # - split into array on '_' (first value of array will be used in SQL) -# 2. Generate WHERE clause using first value of locale array: +# 2) Generate WHERE clause using first value of locale array: # WHERE TwoCharacterSapLanguageCode_LAISO = 'ES' -# 3. If the languague_map_sdt view used in either Balance Sheet or Profit and Loss Explores, +# 3) If this View is used in either Balance Sheet or Profit and Loss Explores, # add another condition to WHERE clause: # AND LanguagueKey_SPRAS in (select distinct languageKey_SPRAS FROM BalanceSheet (or ProfitAndLoss)) -# 4. To ensure English is used if locale value does not match SAP LAISO code or not part of +# 4) To ensure English is used if locale value does not match SAP LAISO code or not part of # Balance Sheet or Profit and Loss data, add UNION ALL to always include English as a row # UNION ALL SELECT 'E' as LanguageKey_SPRAS -# 5. Limit to only 1 row, keeping a valid locale value first and English second +# 5) Apply 'LIMIT 1' to return 1 row, keeping a valid locale value first and English second +# +# HOW TO USE +# This View can be joined to balance_sheet or other views which require language_key_spras. When +# including this View in an Explore, recommend: +# - using `always_join` so that language is automatically filtered for the use +# - setting `fields:` property to [] so that no fields from language_map_sdt are +# visible in the Explore # -# JOIN this view as inner join to materials_MD and others which require language_key_spras # For example: # explore: profit_and_loss { # always_join: [language_map_sdt] diff --git a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml index 68ac5d85..3941fcb3 100644 --- a/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_01_reporting_fiscal_periods_sdt.view.lkml @@ -1,6 +1,6 @@ #########################################################{ # PURPOSE -# Step 1 of 3 in deriving Reporting and Comparison Groups of timeframes +# Step 1 of 3 in deriving Reporting and Comparison Groups of timeframes. Step 01 returns Reporting periods. # # SOURCE # View profit_and_loss_fiscal_periods_sdt @@ -12,41 +12,43 @@ # PROCESS FOR STEP 1 - DERIVE REPORTING SELECTION # 1) Captures user inputs from parameters and filters: # profit_and_loss.parameter_display_time_dimension -- filter and display either Fiscal Year, Fiscal Quarter or Fiscal Period +# profit_and_loss.filter_fiscal_timeframe -- select one or more fiscal timeframes (either Year, Quarter or Fiscal Period) to include in Income Statement report # profit_and_loss.parameter_compare_to -- compare selected reporting timeframe to either same timeframe last year, the prior timeframe or no comparison # profit_and_loss.parameter_aggregate -- If "yes" is selected, all selected timeframes will be combined into a single Reporting/Comparison Group. Otherwise, each selected timeframe will be displayed separately in the report. -# profit_and_loss.filter_fiscal_timeframe -- select one or more fiscal timeframes (either Year, Quarter or Fiscal Period) to include in Income Statement report # # 2) Builds SQL statement based on parameter values selected. Returns the fiscal periods # representing the "Reporting" group. # # 3) Derives new dimensions: -# fiscal_reporting_group -- value of "Reporting" +# fiscal_reporting_group -- assigned a value of "Reporting" # alignment_group -- if parameter_aggregate = 'Yes' assign 1 else -# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. +# derive with DENSE_RANK() based on order of fiscal year, quarter or period. # -# If multiple timeframes selected and Aggregate = 'No', each set comparisons will be given a unique group number -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: +# If multiple timeframes selected and parameter_aggregate = 'No', each set comparisons will be given a unique group number. +# e.g., when user selects 2024.001 and 2024.002 to compare to a year ago and parameter_aggregate = 'No', two alignment groups are defined as: # alignment group 1 = 2024.001 compared to 2023.001 # alignment group 2 = 2024.002 compared to 2023.002 # -# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: +# If multiple timeframes selected and parameter_aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., when user selects 2024.001 and 2024.002 to compare to a year ago, one alignment group is defined as: # alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 # -# selected_timeframe -- returns values for either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension -# timeframe_join -- added if parameter_compare_to != 'none'; used in Step 2 to join between reporting and profit_and_loss_fiscal_periods_sdt to derive comparison periods +# selected_timeframe -- returns fiscal year, quarter or period values based on parameter_display_time_dimension +# timeframe_join -- this portion of SQL added if parameter_compare_to != 'none'; used in Step 02 to help derive comparison periods # -- if parameter_compare_to = 'yoy' then fiscal_year_period -# else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then use the [timeframe]_rank for the selected timeframe +# else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then use the [timeframe]_rank # else if parameter_compare_to = 'prior' and parameter_aggregate = 'No' then use the selected timeframe field (fiscal_year_period, fiscal_year_quarter or fiscal_year) # -# prior_timeframe_join -- added if parameter_compare_to != 'none'; used in Step 2 to join between reporting and profit_and_loss_fiscal_periods_sdt to derive comparison periods +# prior_timeframe_join -- this portion of SQL added if parameter_compare_to != 'none'; used in Step 02 to help derive comparison periods # -- if parameter_compare_to = 'yoy' then yoy_fiscal_year_period -# -- else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then derive as: +# else if parameter_compare_to = 'prior' and parameter_aggregate = 'Yes' then derive as: # [timeframe]_rank + ( # max([timeframe]_rank) over (partition by glhierarchy, company_code) - # min([timeframe]_rank) over (partition by glhierarchy, company_code) ) + 1 -# -- else if paramter_compare_to = 'prior' and parameter_aggregate = 'No' then derive as: +# else if paramter_compare_to = 'prior' and parameter_aggregate = 'No' then derive as: # prior_[timeframe] +# NOTE +# This view is only referenced in another view and does not define any dimensions or measures. #########################################################} include: "/views/profit_and_loss_fiscal_periods_sdt.view" @@ -61,45 +63,44 @@ view: profit_and_loss_01_reporting_fiscal_periods_sdt { {% assign window_partition = "(PARTITION BY glhierarchy, company_code)" %} {% if time_level == 'fp' %}{% assign timeframe_field = "fiscal_year_period" %}{% assign is_partial_sql = "false" %} {% elsif time_level == 'qtr' %}{% assign timeframe_field = "fiscal_year_quarter" %} - {% assign is_partial_sql = "is_qtd" %} + {% assign is_partial_sql = "is_qtd" %} {% elsif time_level == 'yr' %}{% assign timeframe_field = "fiscal_year" %}{% assign is_partial_sql = "is_ytd" %} {% else %}{% assign is_partial_sql = "" %} {% endif %} {% assign rank_field = timeframe_field | append: "_rank" %} - {% if comparison_type == 'yoy' %} + {% if comparison_type == 'yoy' %} {% assign timeframe_join_sql = "fiscal_year_period" %} {% assign prior_timeframe_join_sql = "yoy_fiscal_year_period" %} - {% elsif comparison_type == 'prior' and aggregate == 'Yes' %} + {% elsif comparison_type == 'prior' and aggregate == 'Yes' %} {% assign timeframe_join_sql = timeframe_field | append: "_rank" %} {% assign prior_timeframe_join_sql = rank_field | append: " + (max(" | append: rank_field | append: ") over (window_pk) - min(" | append: rank_field | append: ") over (window_pk) + 1 )" %} - {% elsif comparison_type == 'prior' and aggregate == 'No' %} + {% elsif comparison_type == 'prior' and aggregate == 'No' %} {% assign timeframe_join_sql = timeframe_field %} {% assign prior_timeframe_join_sql = "prior_" | append: timeframe_field %} - {% endif %} + {% endif %} - {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} + {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (ORDER BY " | append: timeframe_field | append: " DESC)" %} - {% endif %} - - + {% endif %} - SELECT glhierarchy, - company_code, - fiscal_year, - fiscal_period, - fiscal_quarter, - fiscal_year_quarter, - fiscal_year_period, - period_order_in_quarter, - {{alignment_group_sql}} AS alignment_group, - {{timeframe_field}} AS selected_timeframe, - {% if comparison_type != "none" %} - {{timeframe_join_sql}} as timeframe_join, - {{prior_timeframe_join_sql}} as prior_timeframe_join, - {% endif %} - {{is_partial_sql}} as is_partial_timeframe, - 'Reporting' AS fiscal_reporting_group + SELECT + glhierarchy, + company_code, + fiscal_year, + fiscal_period, + fiscal_quarter, + fiscal_year_quarter, + fiscal_year_period, + period_order_in_quarter, + {{alignment_group_sql}} AS alignment_group, + {{timeframe_field}} AS selected_timeframe, + {% if comparison_type != "none" %} + {{timeframe_join_sql}} as timeframe_join, + {{prior_timeframe_join_sql}} as prior_timeframe_join, + {% endif %} + {{is_partial_sql}} as is_partial_timeframe, + 'Reporting' AS fiscal_reporting_group FROM ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} fp WHERE {% condition profit_and_loss.filter_fiscal_timeframe %}{{timeframe_field}}{% endcondition %} WINDOW window_pk AS {{window_partition}} diff --git a/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml index 90afee49..6fecee80 100644 --- a/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_02_comparison_fiscal_periods_sdt.view.lkml @@ -1,22 +1,27 @@ #########################################################{ -# Step 2 of 3 in deriving Reporting and Comparison Groups of fiscal periods -# Step 2 - Derive Comparison periods based on Reporting selection -# This SQL Derived Table (sdt) uses these views: -# profit_and_loss_fiscal_periods_sdt (aliased below as comp) -# profit_and_loss_01_reporting_fiscal_periods_sdt (aliased below as rep) +# PURPOSE +# Step 2 of 3 in deriving Reporting and Comparison Groups of timeframes. Step 01 returns Comparison periods. # -# Purpose: -# 1) Takes user inputs from parameters and filters: -# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report -# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison -# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Period else each timeframe selected will be displayed in report -# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report +# SOURCE +# View profit_and_loss_fiscal_periods_sdt # -# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters -# and filters to return the "Comparison" timeframes +# REFERENCED BY +# VIEW profit_and_loss_fiscal_periods_sdt (aliased in SQL below as comp) +# VIEW profit_and_loss_01_reporting_fiscal_periods_sdt (aliased in SQL below as rep) +# +# PROCESS FOR STEP 2 - DERIVE COMPARISON PERIODS +# 1) Captures user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension -- filter and display either Fiscal Year, Fiscal Quarter or Fiscal Period +# profit_and_loss.filter_fiscal_timeframe -- select one or more fiscal timeframes (either Year, Quarter or Fiscal Period) to include in Income Statement report +# profit_and_loss.parameter_compare_to -- compare selected reporting timeframe to either same timeframe last year, the prior timeframe or no comparison +# profit_and_loss.parameter_aggregate -- If "yes" is selected, all selected timeframes will be combined into a single Reporting/Comparison Group. Otherwise, each selected timeframe will be displayed separately in the report. +# +# 2) If parameter_compare_to != 'none', builds SQL statement based on parameter values selected. Returns the fiscal periods +# representing the "Comparison" group. +# +# Establishes Comparison group with a JOIN between profit_and_loss_01_reporting_fiscal_periods_sdt and profit_and_loss_fiscal_periods_sdt +# using either yoy_ or prior_[fiscal timeframe] # -# Uses a JOIN between profit_and_loss_01_reporting_fiscal_periods_sdt and profit_and_loss_fiscal_periods_sdt to derive the comparison period -# using either yoy or prior fiscal year/fiscal year quarter/fiscal year period # For example, if user selects to display Fiscal Period and compare to last year, # the derived join statement will be: # FROM profit_and_loss_01_reporting_fiscal_periods_sdt rep @@ -34,23 +39,26 @@ # AND rep.prior_fiscal_quater_rank = comp.fiscal_year_quarter_rank # AND rep.period_order_in_quarter = comp.period_order_in_quarter # -# NOTE, If the user selects a partial year or quarter, the comparison period will also be a partial year or quarter -# # 3) Derives new dimensions: -# fiscal_reporting_group -- value of Comparison +# fiscal_reporting_group -- assigned value of Comparison # alignment_group -- if parameter_aggregate = 'Yes' assign 1 else -# derive with DENSE_RANK() based on Order of fiscal year, quarter or period. If multiple timeframes selected, each set of comparisons will be given a unique group number +# derive with DENSE_RANK() based on order of fiscal year, quarter or period. # -# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: +# If multiple timeframes selected and parameter_aggregate = 'No', each set of comparisons will be given a unique group number +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and parameter_aggregate = 'No', two alignment groups are defined as: # alignment group 1 = 2024.001 compared to 2023.001 # alignment group 2 = 2024.002 compared to 2023.002 # -# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: +# If multiple timeframes selected and parameter_aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, one alignment gorup is defined as: # alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 # -# selected_timeframe -- returns either fiscal_year, fiscal_year_quarter or fiscal_year_period based on parameter_display_time_dimension +# selected_timeframe -- returns fiscal year, quarter or period values based on parameter_display_time_dimension +# +# NOTES +# This view is only referenced in another view and does not define any dimensions or measures. +# If the user selects a partial year or quarter, the comparison period will also be a partial year or quarter. +# If comparison = "none" a dummy SQL statement is generated and no comparison period will be derived #########################################################} include: "/views/profit_and_loss_fiscal_periods_sdt.view" @@ -63,57 +71,56 @@ view: profit_and_loss_02_comparison_fiscal_periods_sdt { sql: {% assign comparison_type = profit_and_loss.parameter_compare_to._parameter_value %} - {% if comparison_type != "none" %} - {% assign time_level = profit_and_loss.parameter_display_time_dimension._parameter_value %} - {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} - {% assign window_partition = "(PARTITION BY comp.glhierarchy, comp.company_code)" %} - {% if time_level == 'fp' %} - {% assign timeframe_field = "fiscal_year_period" %} - {% assign join2_sql = "" %} - {% elsif time_level == 'qtr' %} - {% assign timeframe_field = "fiscal_year_quarter" %} - {% assign join2_sql = "AND rep.period_order_in_quarter = comp.period_order_in_quarter" %} - {% elsif time_level == 'yr' %} - {% assign timeframe_field = "fiscal_year" %} - {% assign join2_sql = "AND rep.fiscal_period = comp.fiscal_period" %} - {% endif %} - {% assign rank_field = timeframe_field | append: "_rank" %} - - {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} - {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (ORDER BY comp." | append: timeframe_field | append: " DESC)" %} - {% endif %} + {% if comparison_type != "none" %} + {% assign time_level = profit_and_loss.parameter_display_time_dimension._parameter_value %} + {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} + {% assign window_partition = "(PARTITION BY comp.glhierarchy, comp.company_code)" %} + {% if time_level == 'fp' %} + {% assign timeframe_field = "fiscal_year_period" %} + {% assign join2_sql = "" %} + {% elsif time_level == 'qtr' %} + {% assign timeframe_field = "fiscal_year_quarter" %} + {% assign join2_sql = "AND rep.period_order_in_quarter = comp.period_order_in_quarter" %} + {% elsif time_level == 'yr' %} + {% assign timeframe_field = "fiscal_year" %} + {% assign join2_sql = "AND rep.fiscal_period = comp.fiscal_period" %} + {% endif %} + {% assign rank_field = timeframe_field | append: "_rank" %} - {% if comparison_type == 'yoy' %}{% assign timeframe_join_sql = "fiscal_year_period" %} - {% elsif comparison_type == 'prior' and aggregate == 'Yes' %}{% assign timeframe_join_sql = timeframe_field | append: "_rank" %} - {% elsif comparison_type == 'prior' and aggregate == 'No' %}{% assign timeframe_join_sql = timeframe_field %} - {% else %}{% assign timeframe_join_sql = "" %} - {% endif %} + {% if aggregate == 'Yes' %}{% assign alignment_group_sql = '1' %} + {% else %}{% assign alignment_group_sql = "DENSE_RANK() OVER (ORDER BY comp." | append: timeframe_field | append: " DESC)" %} + {% endif %} - {% assign join1_sql = "AND rep.prior_timeframe_join = comp." | append: timeframe_join_sql %} + {% if comparison_type == 'yoy' %}{% assign timeframe_join_sql = "fiscal_year_period" %} + {% elsif comparison_type == 'prior' and aggregate == 'Yes' %}{% assign timeframe_join_sql = timeframe_field | append: "_rank" %} + {% elsif comparison_type == 'prior' and aggregate == 'No' %}{% assign timeframe_join_sql = timeframe_field %} + {% else %}{% assign timeframe_join_sql = "" %} + {% endif %} + {% assign join1_sql = "AND rep.prior_timeframe_join = comp." | append: timeframe_join_sql %} - SELECT - comp.glhierarchy, - comp.company_code, - comp.fiscal_year_period, - comp.fiscal_year_quarter, - comp.fiscal_year, - comp.fiscal_period, - {{alignment_group_sql}} AS alignment_group, - comp.{{timeframe_field}} AS selected_timeframe, - rep.is_partial_timeframe, - 'Comparison' AS fiscal_reporting_group - FROM ${profit_and_loss_01_reporting_fiscal_periods_sdt.SQL_TABLE_NAME} rep - JOIN ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} comp - ON rep.glhierarchy = comp.glhierarchy - AND rep.company_code = comp.company_code - {{join1_sql}} - {{join2_sql}} - WINDOW window_pk AS {{window_partition}} + SELECT + comp.glhierarchy, + comp.company_code, + comp.fiscal_year_period, + comp.fiscal_year_quarter, + comp.fiscal_year, + comp.fiscal_period, + {{alignment_group_sql}} AS alignment_group, + comp.{{timeframe_field}} AS selected_timeframe, + rep.is_partial_timeframe, + 'Comparison' AS fiscal_reporting_group + FROM ${profit_and_loss_01_reporting_fiscal_periods_sdt.SQL_TABLE_NAME} rep + JOIN ${profit_and_loss_fiscal_periods_sdt.SQL_TABLE_NAME} comp + ON rep.glhierarchy = comp.glhierarchy + AND rep.company_code = comp.company_code + {{join1_sql}} + {{join2_sql}} + WINDOW window_pk AS {{window_partition}} - {% else %} - SELECT 1 as dummy_field - {% endif %} + {% else %} + SELECT 1 as dummy_field + {% endif %} ;; } diff --git a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml index ce788457..3e41eb5f 100644 --- a/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_03_selected_fiscal_periods_sdt.view.lkml @@ -1,51 +1,60 @@ #########################################################{ -# Step 3 of 3 in deriving Reporting and Comparison Groups -# Step 3 - Combine Reporting and Comparison Groups -# This SQL Derived Table (sdt) uses these views: -# profit_and_loss_01_reporting_fiscal_periods_sdt (aliased below as rep) -# profit_and_loss_02_comparison_fiscal_periods_sdt (aliased below as comp) +# PURPOSE +# Step 3 of 3 in deriving Reporting and Comparison Groups. Step 03 returns combination of Reporting and Comparison periods. # -# Keys to using this view: +# SOURCE +# VIEW profit_and_loss_01_reporting_fiscal_periods_sdt (aliased in SQL below as rep) +# VIEW profit_and_loss_02_comparison_fiscal_periods_sdt (aliased in SQL below as comp) +# +# REFERENCED BY +# Explore profit_and_loss +# +# KEYS TO USING THIS VIEW # - View label is "Reporting vs. Comparison Period" -# - Fields are hidden by default so must change hidden: property to no to include in an explore -# - includes references to fields from view profit_and_loss so always join this view to profit_and_loss using an inner join on: +# - Fields are hidden by default so must change a field's "hidden: property" to "no" to include in an Explore +# - Measures include references to fields from View profit_and_loss so must join this view to profit_and_loss using an inner join on: # glhierarchy, company_code, fiscal_year, fiscal_period -# Note, the profit_and_loss_fiscal_periods_sdt view already filters to the same Client id so it is not needed in the join. +# Note, the source view already filters to a single Client id so it is not needed in the join # -# Purpose: -# 1) Takes user inputs from parameters and filters: -# profit_and_loss.parameter_display_time_dimension - use either Year, Quarter or Period for timeframes in report -# profit_and_loss.parameter_compare_to - - compare timeframes selected to either same period(s) last year, most recent period(s) prior or no comparison -# profit_and_loss.parameter_aggregate - if yes, all timeframes selected will be aggregated into Reporting/Comparison Period else each timeframe selected will be displayed in report -# profit_and_loss.filter_fiscal_timeframe - select one or more fiscal periods to include in Income Statement report +# PROCESS FOR STEP 3 - COMBINE REPORTING AND COMPARISON PERIODS +# 1) Captures user inputs from parameters and filters: +# profit_and_loss.parameter_display_time_dimension -- filter and display either Fiscal Year, Fiscal Quarter or Fiscal Period +# profit_and_loss.filter_fiscal_timeframe -- select one or more fiscal timeframes (either Year, Quarter or Fiscal Period) to include in Income Statement report +# profit_and_loss.parameter_compare_to -- compare selected reporting timeframe to either same timeframe last year, the prior timeframe or no comparison +# profit_and_loss.parameter_aggregate -- If "yes" is selected, all selected timeframes will be combined into a single Reporting/Comparison Group. Otherwise, each selected timeframe will be displayed separately in the report. # -# 2) Using Liquid, builds SQL statement on the fly based on values selected for above parameters -# and combines "Reporting" and "Comparison" rows using UNION ALL +# 2) Builds SQL statement based on parameter values selected. Returns the fiscal periods +# representing the "Reporting" and "Comparison" periods using UNION ALL statement. +# The UNION operator is utilized to combine data from the Reporting period and +# the Comparison period, as certain periods may overlap in both. # # 3) Derives new dimensions: # alignment_group_name -- if parameter_aggregate = 'Yes' assign list of timeframes selected else -# derive with MAX([timeframe]) OVER (glhierarchy, company_code, alignment_group) +# derive with MAX([timeframe]) OVER (alignment_group) # -# If multiple timeframes selected and Aggregate = 'No', each set of comparisons will be given a unique group number -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year and Aggregate = 'No', two alignment groups will be defined as: -# alignment group 1 = 2024.001 compared to 2023.001 and alignment_group_name = 2024.001 -# alignment group 2 = 2024.002 compared to 2023.002 and alignment_group_name = 2024.002 +# If multiple timeframes selected and parameter_aggregate = 'No', each set of comparisons will be given a unique group number. +# e.g., if user selects 2024.001 and 2024.002 to compare to a year ago and parameter_aggregate = 'No', two alignment groups will be defined as: +# alignment group 1 = 2024.001 compared to 2023.001 and alignment_group_name = 2024.001 +# alignment group 2 = 2024.002 compared to 2023.002 and alignment_group_name = 2024.002 # -# If multiple timeframes selected and Aggregate = 'Yes', all timeframes will be combined into 1 alignment group. -# e.g., if user selects 2024.001 and 2024.002 to compare to same periods last year, two alignment groups with focus_timeframe labels will be defined as: -# alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 -# and alignment_group_name = 2024.001, 2024.002 +# If multiple timeframes selected and parameter_aggregate = 'Yes', all timeframes will be combined into 1 alignment group. +# e.g., if user selects 2024.001 and 2024.002 to compare to a year ago, one alignment group is defined as: +# alignment group 1 = 2024.001 + 2024.002 compared to 2023.001 + 2023.002 +# and alignment_group_name = 2024.001, 2024.002 # # reporting_timeframes_list -- captures the values selected in filter_fiscal_timeframe as a string (e.g., 2024.001, 2024.002, 2024.003) -# is_partial_timeframe -- Value of true if selected_timeframe (fiscal_year/fiscal_year_quarter) is incomplete else false. Note does not check if fiscal_year_period is incomplete +# is_partial_timeframe -- value of true if selected_timeframe (fiscal_year/fiscal_year_quarter) is incomplete else false. Note does not check if fiscal_year_period is incomplete # is_partial_timeframe_in_alignment_group -- If any of the timeframes in the alignment_group are incomplete then true else false # -# 4) Defines reporting measures: -# reporting_amount -# comparison_amount -# difference_value -# difference_percent +# MEASURES +# reporting_amount -- SUM(Amount in Target Currency) when fiscal_reporting_group = 'Reporting' +# comparison_amount -- SUM(Amount in Target Currency) when fiscal_reporting_group = 'Comparison' +# difference_value -- reporting_amount - comparison_amount +# difference_percent -- (reporting_amount - comparison_amount) / abs(comparison_amount) # +# NOTE +# Only fiscal_year and fiscal_year_quarter are flagged for incompleteness. +# If the user selects a partial year or quarter, the comparison period will also be a partial year or quarter. ##########################################################} include: "/views/profit_and_loss_0*.view" @@ -61,7 +70,7 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { {% assign tp_list = _filters['profit_and_loss.filter_fiscal_timeframe'] | sql_quote | remove: '"' | remove: "'" | replace: ",",", " | split: ", " %} {% assign tp_list = tp_list | sort | join: ", " %} {% assign aggregate = profit_and_loss.parameter_aggregate._parameter_value %} - {% assign window_alignment = "(PARTITION BY glhierarchy, alignment_group)" %} + {% assign window_alignment = "(PARTITION BY alignment_group)" %} {% if time_level == "f" %}{% assign time_level_sql = "Fiscal Year Period"%}{%elsif time_level == "q"%}{% assign time_level_sql = "Fiscal Quarter"%}{%elsif time_level == "y" %}{% assign time_level_sql = "Fiscal Year"%}{% else %}{% assign time_level_sql = "None"%}{%endif%} {% if aggregate == 'Yes' %}{% assign alignment_group_name_sql = "'" | append: tp_list | append: "'" %} {% else %}{% assign alignment_group_name_sql = "MAX(selected_timeframe) OVER (window_alignment)" %} @@ -247,30 +256,6 @@ view: profit_and_loss_03_selected_fiscal_periods_sdt { sql: CASE WHEN ${is_partial_timeframe} THEN CONCAT(${selected_timeframe},"*") ELSE ${selected_timeframe} END ;; } - dimension: selected_timeframe_comparison { - type: string - hidden: yes - sql: case when ${fiscal_reporting_group} = "Comparison" then ${selected_timeframe_label} end ;; - } - - dimension: selected_timeframe_reporting { - type: string - hidden: yes - sql: case when ${fiscal_reporting_group} = "Reporting" then ${selected_timeframe_label} end ;; - } - - dimension: fiscal_year_period_comparison { - type: string - hidden: yes - sql: case when ${fiscal_reporting_group} = "Comparison" then ${fiscal_year_period} end ;; - } - - dimension: fiscal_year_period_reporting { - type: string - hidden: yes - sql: case when ${fiscal_reporting_group} = "Reporting" then ${fiscal_year_period} end ;; - } - measure: reporting_amount { type: sum_distinct hidden: no diff --git a/views/profit_and_loss_fiscal_periods_sdt.view.lkml b/views/profit_and_loss_fiscal_periods_sdt.view.lkml index 88de878d..b0f04210 100644 --- a/views/profit_and_loss_fiscal_periods_sdt.view.lkml +++ b/views/profit_and_loss_fiscal_periods_sdt.view.lkml @@ -1,12 +1,21 @@ #########################################################{ +# PURPOSE # Finds the Fiscal Years and Periods available in Profit and Loss -# and derives: -# prior dimension for fiscal year, quarter and period -# year ago fiscal period -# max fiscal period in a fiscal year (used to identify YTD selections) -# max periods in a quarter (used for identify QTD selections) +# And derives the following fields: +# - fiscal_year_period +# - year ago fiscal period +# - max fiscal period in a fiscal year (used to identify YTD selections) +# - max periods in a quarter (used for identify QTD selections) # -# Used as source for finding Current and Comparison Periods based on user selection +# SOURCE +# Table @{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss +# +# REFERENCED BY +# View profit_and_loss_01_reporting_fiscal_periods_sdt +# View profit_and_loss_02_comparison_fiscal_periods_sdt +# +# NOTE +# This view is only referenced in other views and does not define any dimensions or measures. #########################################################} view: profit_and_loss_fiscal_periods_sdt { @@ -21,9 +30,9 @@ view: profit_and_loss_fiscal_periods_sdt { fiscal_period, CONCAT(fiscal_year,'.Q',fiscal_quarter) AS fiscal_year_quarter, CONCAT(fiscal_year,'.',fiscal_period) as fiscal_year_period, - rank() over (partition by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_period) desc) as fiscal_year_period_rank, - dense_rank() over (partition by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_quarter) desc) as fiscal_year_quarter_rank, - dense_rank() over (partition by glhierarchy, company_code order by fiscal_year desc) as fiscal_year_rank, + RANK() over (PARTITION by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_period) desc) as fiscal_year_period_rank, + DENSE_RANK() over (PARTITION by glhierarchy, company_code order by CONCAT(fiscal_year,'.',fiscal_quarter) desc) as fiscal_year_quarter_rank, + DENSE_RANK() over (PARTITION by glhierarchy, company_code order by fiscal_year desc) as fiscal_year_rank, --prior fiscal year, quarter and period CAST(PARSE_NUMERIC(fiscal_year) - 1 AS STRING) as prior_fiscal_year, LAG(CONCAT(fiscal_year,'.Q',fiscal_quarter),3) OVER (PARTITION BY glhierarchy, company_code ORDER BY fiscal_year, fiscal_quarter) as prior_fiscal_year_quarter, diff --git a/views/profit_and_loss_hierarchy_selection_sdt.view.lkml b/views/profit_and_loss_hierarchy_selection_sdt.view.lkml index 4a68848a..68f2bab9 100644 --- a/views/profit_and_loss_hierarchy_selection_sdt.view.lkml +++ b/views/profit_and_loss_hierarchy_selection_sdt.view.lkml @@ -1,26 +1,46 @@ -#########################################################{ -# This SQL Derived Table (sdt): -# 1) Takes user inputs from parameters: -# parameter_pick_start_level - select top level of hierarchy to show -# parameter_pick_depth_level - how many levels should be shown (1 to 5 levels) +######################################################### +# PURPOSE +# SQL Derived Table (SDT) to select the Node levels to display in Income Statement report. Assigns values to Hier1_node_text to Heir5_node_text based on user inputs. +# +# SOURCES +# View profit_and_loss_path_to_node_pdt +# Extends View common_hierarchy_fields_finance_ext +# +# REFERENCED BY +# Explore profit_and_loss +# +# KEYS TO USING +# - View label is "Income Statement" +# - Fields are hidden by default so must change field's "hidden: property" to "no" to include in an Explore +# +# PROCESS +# 1) Captures inputs from parameters: +# parameter_pick_start_level -- select top level of hierarchy to show +# parameter_pick_depth_level -- how many levels should be shown (1 to 5 levels) # 2) Derives node_text and node values for hier1 to hier5 by placing the top level selected by user into hier_1 and subsequent levels into hier2 to hier5 -# 3) Filters applied: -# first level of the hierarchy = top level selected AND -# (level number = last level selected by user OR -# level number < last level AND GLIsLeafNode = true) -# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level AND -# levels 2 and 3 where GLIsLeafNode = true will also be selected +# 3) Filters to keep: +# Hier1_node = top level selected AND +# (Child Level Number = last level selected by user OR +# Child Level Number < last level AND IsLeafNode = true) +# +# For example, if Top Level to Display of 2 and a depth of 3 is selected, level 4 will be selected as the lowest level. +# Additionally, levels 2 and 3, where GLIsLeafNode equals true, will also be selected. # -# If more than 5 hierarchy levels are needed, update the parameter_pick_depth_level and add additional hierN dimensions for node and node_text +# CAVEATS +# If more than 5 hierarchy levels are needed: +# - update the parameter_pick_depth_level to accept additional values +# - add additional hierN SQL statements +# - add additional dimensions in this view OR in extended view common_hierarchy_fields_finance_ext if also needed in other views # -# EXTENDED FIELDS: -# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext: +# EXTENDED FIELDS +# The following parameters and dimensions are extended from view common_hierarchy_fields_finance_ext +# and can be further customized for Income Statement reporting: # parameter_pick_start_level # parameter_pick_depth_level # hier1_node_text ... hier5_node_text # hier1_node ... hier5_node # -# This view should be joined to profit_and_loss using an inner join on: +# PRIMARY KEY # client_mandt # glhierarchy # chart_of_accounts diff --git a/views/profit_and_loss_navigation_ext.view.lkml b/views/profit_and_loss_navigation_ext.view.lkml index 489bb08b..4247d540 100644 --- a/views/profit_and_loss_navigation_ext.view.lkml +++ b/views/profit_and_loss_navigation_ext.view.lkml @@ -1,39 +1,52 @@ #########################################################{ -# Extends and modifies navigation_template to support navigation between -# related Income Statement Dashboards: With Comparisons and No Comparisons +# PURPOSE +# Dynamically generates html links (including filters) to supports navigation between +# related Income Statements (With Comparisons and No Comparisons) # -# Two sets of LookML dashboards are included: -# - Marketplace Report Table With Comparisons (income_statement_mktplace_report_table) -# and Without Comparisons (income_statement_mktplace_report_table_no_comparisons) +# SOURCE +# Extends View navigation_template +# +# REFERENCED BY +# Explore profit_and_loss +# Dashboards: +# - Marketplace With Comparisons (income_statement_mktplace_report_table) +# - Marketplace Without Comparisons (income_statement_mktplace_report_table_no_comparison) # - Subtotal Table With Comparisons (income_statement_subtotal_table) -# and Without Comparisons (income_statement_subtotal_table_no_comparisons) +# - Subtotal Table Without Comparisons (income_statement_subtotal_table_no_comparison) +# +# CUSTOMIZATIONS +# While the navigation_template provides much of the logic needed, customizations for Income Statement +# are required. +# 1. Added new parameter "navigation_which_dashboard_style" +# Used to dynamically derive LookML dashboard name for dash_bindings based on parameter setting # -# Because of these two sets of dashboards ADDED a parameter navigation_which_dashboard_style -# to dynamically derive LookML dashboard name based on parameter setting +# 2. dash_bindings -- added dynamic dashboard name and link text for each dashboard +# dashboard name link text +# --------------- --------------- +# income_statement_{% parameter navigation_which_dashboard_style %}_table With Comparisons +# income_statement_{% parameter navigation_which_dashboard_style %}_table_no_comparison No Comparisons # -# Other customizations: -# dash_bindings: added dashboard and link names -# filter_bindings: added 8 filters and corresponding URL values -# filter label URL format -# ------- --------------- --------------------- -# filter1 Hierarchy Hierarchy -# filter2 Display Timeframe Display+Timeframe -# filter3 Select Fiscal Timeframe Select+Fiscal+Timeframe -# filter4 Global Currency Global+Currency -# filter5 Company Company -# filter6 Ledger Name Ledger+Name -# filter7 Top Hierarchy Level to Display Top+Hierarchy+Level+to+Display -# filter8 Combine Selected Timeframes? Combine+Selected+Timeframes%3F +# 3. filter_bindings -- added 7 filters and corresponding URL values +# filter label URL format +# ------- --------------- --------------------- +# filter1 Hierarchy Hierarchy +# filter2 Display Timeframe Display+Timeframe +# filter3 Select Fiscal Timeframe Select+Fiscal+Timeframe +# filter4 Global Currency Global+Currency +# filter5 Company Company +# filter6 Ledger Name Ledger+Name +# filter7 Top Hierarchy Level to Display Top+Hierarchy+Level+to+Display +# filter8 Combine Selected Timeframes? Combine+Selected+Timeframes%3F # -# tip: to find URL formats copy url for dashboard and review list of parameters after +# tip: to find URL formats copy url for dashboard and review list of parameters after # [dashboard name]? # -# filter1 to filter8 filters: added labels as indicated above (NOTE: can optionally unhide) -# navigation_focus_page: confirmed allowed values of 1 or 2 -# added group_label = "Navigation" for parameters exposed in the Explore +# 4. filter1 to filter8 filters: added labels as indicated above (NOTE: can optionally unhide) +# 5. navigation_focus_page: confirmed allowed values of 1 or 2 +# 6. added group_label = "Navigation" for parameters exposed in the Explore # -# To use this view: -# 1) Add to an explore using a bare join +# HOW TO USE FOR NAVIGATION +# 1. Add to an Explore using a bare join # explore: profit_and_loss { # join: profit_and_loss_navigation_ext { # view_label: "🔍 Filters & 🛠 Tools" @@ -41,12 +54,14 @@ # sql: ;; # }} # -# 2) Add Navigation to Single Value Visualization and set these paramaters accordingly -# Navigation Style = small -# Navigation Focus Page = 1 (if adding to first dashboard listed, set to 2 if added viz to second dashboard) -# Which Dashboard Style? = subtotal (if adding to one of the subtotal dashboards) +# 2. Add Navigation dimension to Single Value Visualization and set these paramaters accordingly +# Navigation Style = Hyperlinks - Left Aligned - No Border - Small font (or if using lookml, small) +# Navigation Focus Page = 1 (1 if adding to first dashboard listed; set to 2 if adding viz to second dashboard) +# Navigation Which Dashboard Style? = Subtotal Table (or if using lookml, = subtotal) if adding to one of the subtotal dashboards OR +# = Marketplace Table (Report) (or if using lookml, mktplace_report) if adding to one of the Marketplace dashboards # -# 3) Add Navigation visualization to a dashboard and set to map to listen to the dashboard filters +# +# 3. Add Navigation visualization to dashboard and set viz to listen to the dashboard filters # # Below is example Dashboard LookML generated: # - title: navigation @@ -71,7 +86,6 @@ # Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 #########################################################} - include: "/views/navigation_template.view" view: profit_and_loss_navigation_ext { diff --git a/views/profit_and_loss_path_to_node_pdt.view.lkml b/views/profit_and_loss_path_to_node_pdt.view.lkml index fb7e5fde..d567dde6 100644 --- a/views/profit_and_loss_path_to_node_pdt.view.lkml +++ b/views/profit_and_loss_path_to_node_pdt.view.lkml @@ -1,8 +1,18 @@ #########################################################{ -# this Persistent Derived Table (pdt) derives the full path to a node (e.g., Net Income (P&L)/Operating Income/Gross Margin) +# PURPOSE +# This Persistent Derived Table (PDT) derives the full path to a node using RECURSIVE +# to navigate the parent-child relationships. +# For example, for Child Node Gross Margin, the path is: +# Net Income (P&L)-->Operating Income-->Gross Margin # -# Uses RECURSIVE to navigate the parent-child relationships and derive the full path -# This view is only referenced in the view profit_and_loss_hierarchy_selection_sdt +# SOURCE +# Table `@{GCP_PROJECT}.@{REPORTING_DATASET}.ProfitAndLoss` +# +# REFERENCED BY +# View profit_and_loss_hierarchy_selection_sdt +# +# UPDATE SCHEDULE +# triggered when distinct count of nodes changes (see datagroup trigger profit_and_loss_node_count) #########################################################} view: profit_and_loss_path_to_node_pdt { diff --git a/views/profit_and_loss_rfn.view.lkml b/views/profit_and_loss_rfn.view.lkml index 9994256d..f4816769 100644 --- a/views/profit_and_loss_rfn.view.lkml +++ b/views/profit_and_loss_rfn.view.lkml @@ -1,7 +1,6 @@ #########################################################{ -# With this reporting view, users can report on any of the FSV nodes and corresponding amounts will be rolled up or down according to node values -# -# aggregation of General Ledger Transactions by the following dimensions: +# PURPOSE +# The ProfitAndLoss table and its corresponding View profit_and_loss reflects an aggregation of General Ledger Transactions by the following dimensions: # Client # Fiscal Year # Fiscal Period @@ -16,24 +15,33 @@ # Languague # Global (Target) Currency # -# Measures: +# SOURCES +# Refines View profit_and_loss (defined in file profit_and_loss_base.view) +# Extends View common_fields_finance_ext +# +# REFERENCED BY +# Explore profit_and_loss +# +# EXTENDED FIELDS +# Extends common dimensions found in both balance sheet and profit and loss +# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, +# fiscal_period, fiscal_quarter, fiscal_year and related fields +# Make changes to these dimensions in the common_fields_finance_ext view or +# in this view if the changes are specific to Profit and Loss. +# +# KEY MEASURES # Amount in Local Currency, Amount in Global Currency # Cumulative Amount in Local Currency, Cumulative Amount in Global Currency # Exchange Rate (based on last date in the period) # Avg Exchange Rate, Max Exchange Rate # +# HOW TO USE # To query this table, filter to: # - a single Client MANDT (handled with Constant defined in Manifest file) # - a single Language (the Explore based on this view uses User Attribute locale to select language in joined view language_map_sdt) # - a single Global Currency # - a single Hierarchy Name or Financial Statement Version -# - a single Company # -# Extends common dimensions found in both balance sheet and profit and loss using view common_fields_finance_ext -# client_mandt, language_key_spras, currency_key, target_currency_tcurr, ledger_in_general_ledger_accounting, company_code, company_text, chart_of_accounts, business_area, -# fiscal_period, fiscal_quarter, fiscal_year and related fields -# Make changes to these dimensions in view common_fields_finance_ext if changes are for both balance sheet and profit and loss or; -# Customize these dimensions specifically for Profit and Loss in this view as needed #########################################################} diff --git a/views/universal_ledgers_md_rfn.view.lkml b/views/universal_ledgers_md_rfn.view.lkml index de97c791..ec9f3c8e 100644 --- a/views/universal_ledgers_md_rfn.view.lkml +++ b/views/universal_ledgers_md_rfn.view.lkml @@ -1,3 +1,24 @@ +#########################################################{ +# PURPOSE +# Provide Ledger Name and other details +# +# SOURCE +# Refines View universal_ledgers_md (defined in file universal_ledgers_base.view) +# +# REFERENCED BY +# Explore profit_and_loss +# +# DERIVED DIMENSION +# ledger_id_name -- concatenation of ledger_rldnr and name_name and used for Income Statement dashboard filter +# +# KEYS TO USING +# - Fields are hidden by default so must change "hidden: " property to "no" to include in an Explore +# - currently only Ledger Name and Ledger ID - Name are unhidden +# - this View is labeled "Profit and Loss" when included in Explore profit_and_loss +# - this View is labeled "Balance Sheet" when included in Explore balance_sheet +# +#########################################################} + include: "/views/universal_ledgers_md_base.view" view: +universal_ledgers_md { From 2fdc63684baf4f21a602a15051a96c7cce42d652 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 27 Mar 2024 15:34:43 +0000 Subject: [PATCH 14/16] Balance Sheet: update company dashboard filter to allow multiple values and dashboard title to show list of companies selected --- .../balance_sheet_template.dashboard.lookml | 6 +++--- RELEASE_NOTES.md | 1 + views/balance_sheet_rfn.view.lkml | 10 +++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/LookML_Dashboard/balance_sheet_template.dashboard.lookml b/LookML_Dashboard/balance_sheet_template.dashboard.lookml index 3f2e3aee..d26af734 100644 --- a/LookML_Dashboard/balance_sheet_template.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_template.dashboard.lookml @@ -127,10 +127,10 @@ type: field_filter default_value: "%CENTRAL%" allow_multiple_values: false - required: true + required: false ui_config: - type: dropdown_menu - display: popover + type: tag_list + display: inline explore: balance_sheet field: balance_sheet.company_text diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 11cc2dd7..8e43df82 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,6 +14,7 @@ * Added Balance Sheet dashboard template to minimize edits to filters and other shared dashboard elements. * For Report Table dashboard, changed column order so that variance values appear at the end. * Change labels used in Comparison Type parameter to `Year Ago` and `Prior Fiscal Period`. + * Modify Company filter to allow multiple values. * Profit and Loss / Income Statement: * Added views, explores and dashboards to support `Income Statement` reporting. diff --git a/views/balance_sheet_rfn.view.lkml b/views/balance_sheet_rfn.view.lkml index 86ad6a6c..9d086b9c 100644 --- a/views/balance_sheet_rfn.view.lkml +++ b/views/balance_sheet_rfn.view.lkml @@ -252,9 +252,11 @@ view: +balance_sheet { description: "Used in Balance Sheet dashboard as Summary visualization with Company, Global Currency, Fiscal Period and Current Ratio. Add this measure to a single-value visualizaiton." sql: 1 ;; html: + {% if company_text._is_filtered %}{% assign company_list = list_companies._value | replace: '|RECORD|',', ' %} + {% else %}{% assign company_list = 'All Companies' %}{%endif%}
Balance Sheet
- {{company_text._value}}
+ {{company_list}}
Fiscal Period: {{select_fiscal_period._parameter_value}}    Current Ratio: {{current_ratio._rendered_value}}
Amounts in Millions {{target_currency_tcurr}} @@ -289,6 +291,12 @@ view: +balance_sheet { value_format_name: decimal_4 } + measure: list_companies { + type: list + hidden: yes + list_field: company_text + } + #} end measures } From c2e779882937fd766b3432fc1975978d6ef8bd03 Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 27 Mar 2024 17:42:12 +0000 Subject: [PATCH 15/16] balance sheet: unnhide select reporting measures --- views/balance_sheet_fiscal_periods_selected_sdt.view.lkml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml index 2021aa2a..18cfb20f 100644 --- a/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml +++ b/views/balance_sheet_fiscal_periods_selected_sdt.view.lkml @@ -138,6 +138,7 @@ view: balance_sheet_fiscal_periods_selected_sdt { measure: reporting_period_amount_in_global_currency { type: sum_distinct sql_distinct_key: ${balance_sheet.key} ;; + hidden: no view_label: "Reporting vs. Comparison Period" label_from_parameter: balance_sheet.select_fiscal_period description: "Cumulative Amount in Global Currency for the selected Fiscal Reporting Period" @@ -150,6 +151,7 @@ view: balance_sheet_fiscal_periods_selected_sdt { measure: comparison_period_amount_in_global_currency { type: sum_distinct sql_distinct_key: ${balance_sheet.key} ;; + hidden: no view_label: "Reporting vs. Comparison Period" label: "{% assign compare_to = balance_sheet.select_comparison_type._parameter_value %} {% if balance_sheet.select_fiscal_period._in_query %} @@ -178,6 +180,7 @@ view: balance_sheet_fiscal_periods_selected_sdt { measure: difference_value { type: number + hidden: no view_label: "Reporting vs. Comparison Period" label: "Variance Amount" description: "Reporting Period Amount minus Comparison Period Amount" @@ -188,6 +191,7 @@ view: balance_sheet_fiscal_periods_selected_sdt { measure: difference_percent { type: number + hidden: no view_label: "Reporting vs. Comparison Period" label: "Variance %" description: "Percentage Change between Reporting and Comparison Periods" From 38ed63a20be3892c000a49fe26e64ee69abe810b Mon Sep 17 00:00:00 2001 From: Jennifer Thomas Date: Wed, 27 Mar 2024 22:24:39 +0000 Subject: [PATCH 16/16] Change dashboard filter to use label Company Code --- ...alance_sheet_mktplace_report_table.dashboard.lookml | 4 ++-- .../balance_sheet_subtotal3_table.dashboard.lookml | 6 +++--- .../balance_sheet_template.dashboard.lookml | 6 +++--- ...me_statement_mktplace_report_table.dashboard.lookml | 4 ++-- .../income_statement_subtotal_table.dashboard.lookml | 4 ++-- .../income_statement_template.dashboard.lookml | 10 +++++----- views/balance_sheet_navigation_ext.view.lkml | 8 ++++---- views/common_fields_finance_ext.view.lkml | 4 ++-- views/navigation_template.view.lkml | 4 ++-- views/profit_and_loss_navigation_ext.view.lkml | 8 ++++---- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml index b8f3b437..c1bd3991 100644 --- a/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_mktplace_report_table.dashboard.lookml @@ -82,11 +82,11 @@ Custom Comparison Period: balance_sheet.select_custom_comparison_period Hierarchy: balance_sheet.hierarchy_name Chart of Accounts: balance_sheet.chart_of_accounts - Company: balance_sheet.company_text + Company Code: balance_sheet.company_text Global Currency: balance_sheet.target_currency_tcurr Ledger Name: universal_ledgers_md.ledger_id_name Top Hierarchy Level: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level row: 2 col: 0 width: 24 - height: 13 + height: 13 \ No newline at end of file diff --git a/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml index 7e3d27e1..4fd801e6 100644 --- a/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_subtotal3_table.dashboard.lookml @@ -63,7 +63,7 @@ Custom Comparison Period: balance_sheet.select_custom_comparison_period Hierarchy: balance_sheet.hierarchy_name Chart of Accounts: balance_sheet.chart_of_accounts - Company: balance_sheet.company_text + Company Code: balance_sheet.company_text Global Currency: balance_sheet.target_currency_tcurr Ledger Name: universal_ledgers_md.ledger_id_name Top Hierarchy Level: balance_sheet_hierarchy_selection_sdt.parameter_pick_start_level @@ -87,7 +87,7 @@ Global Currency: balance_sheet_navigation_ext.filter2 Hierarchy: balance_sheet_navigation_ext.filter3 Chart of Accounts: balance_sheet_navigation_ext.filter4 - Company: balance_sheet_navigation_ext.filter5 + Company Code: balance_sheet_navigation_ext.filter5 Ledger Name: balance_sheet_navigation_ext.filter6 Top Hierarchy Level: balance_sheet_navigation_ext.filter7 row: 11 @@ -105,4 +105,4 @@ options: - yoy - prior - - custom + - custom \ No newline at end of file diff --git a/LookML_Dashboard/balance_sheet_template.dashboard.lookml b/LookML_Dashboard/balance_sheet_template.dashboard.lookml index d26af734..3ff0e8b4 100644 --- a/LookML_Dashboard/balance_sheet_template.dashboard.lookml +++ b/LookML_Dashboard/balance_sheet_template.dashboard.lookml @@ -39,7 +39,7 @@ listen: Global Currency: balance_sheet.target_currency_tcurr Chart of Accounts: balance_sheet.chart_of_accounts - Company: balance_sheet.company_text + Company Code: balance_sheet.company_text Fiscal Period: balance_sheet.select_fiscal_period Hierarchy: balance_sheet.hierarchy_name Ledger Name: universal_ledgers_md.ledger_id_name @@ -122,8 +122,8 @@ explore: balance_sheet field: balance_sheet.chart_of_accounts - - name: Company - title: Company + - name: Company Code + title: Company Code type: field_filter default_value: "%CENTRAL%" allow_multiple_values: false diff --git a/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml index 6dbbbe3f..5bc8380f 100644 --- a/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml +++ b/LookML_Dashboard/income_statement_mktplace_report_table.dashboard.lookml @@ -66,7 +66,7 @@ Display Timeframe: profit_and_loss.parameter_display_time_dimension Select Comparison Type: profit_and_loss.parameter_compare_to Ledger Name: universal_ledgers_md.ledger_id_name - Company: profit_and_loss.company_text + Company Code: profit_and_loss.company_text Hierarchy: profit_and_loss.glhierarchy Top Hierarchy Level: profit_and_loss_hierarchy_selection_sdt.parameter_pick_start_level Combine Selected Timeframes?: profit_and_loss.parameter_aggregate @@ -96,4 +96,4 @@ - prior explore: profit_and_loss listens_to_filters: [] - field: profit_and_loss.parameter_compare_to + field: profit_and_loss.parameter_compare_to \ No newline at end of file diff --git a/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml b/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml index 61e3eb7b..e98d8ffb 100644 --- a/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml +++ b/LookML_Dashboard/income_statement_subtotal_table.dashboard.lookml @@ -66,7 +66,7 @@ Display Timeframe: profit_and_loss.parameter_display_time_dimension Select Comparison Type: profit_and_loss.parameter_compare_to Ledger Name: universal_ledgers_md.ledger_id_name - Company: profit_and_loss.company_text + Company Code: profit_and_loss.company_text Hierarchy: profit_and_loss.glhierarchy Top Hierarchy Level: profit_and_loss_hierarchy_selection_sdt.parameter_pick_start_level row: 3 @@ -95,4 +95,4 @@ - prior explore: profit_and_loss listens_to_filters: [] - field: profit_and_loss.parameter_compare_to + field: profit_and_loss.parameter_compare_to \ No newline at end of file diff --git a/LookML_Dashboard/income_statement_template.dashboard.lookml b/LookML_Dashboard/income_statement_template.dashboard.lookml index 77a45226..c6551c1c 100644 --- a/LookML_Dashboard/income_statement_template.dashboard.lookml +++ b/LookML_Dashboard/income_statement_template.dashboard.lookml @@ -46,7 +46,7 @@ Display Timeframe: profit_and_loss.parameter_display_time_dimension Select Comparison Type: profit_and_loss.parameter_compare_to Ledger Name: universal_ledgers_md.ledger_id_name - Company: profit_and_loss.company_text + Company Code: profit_and_loss.company_text Hierarchy: profit_and_loss.glhierarchy row: 2 col: 0 @@ -65,7 +65,7 @@ Display Timeframe: profit_and_loss.parameter_display_time_dimension Select Comparison Type: profit_and_loss.parameter_compare_to Ledger Name: universal_ledgers_md.ledger_id_name - Company: profit_and_loss.company_text + Company Code: profit_and_loss.company_text Hierarchy: profit_and_loss.glhierarchy Combine Selected Timeframes?: profit_and_loss.parameter_aggregate row: 10 @@ -89,7 +89,7 @@ Display Timeframe: profit_and_loss_navigation_ext.filter2 Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 Global Currency: profit_and_loss_navigation_ext.filter4 - Company: profit_and_loss_navigation_ext.filter5 + Company Code: profit_and_loss_navigation_ext.filter5 Ledger Name: profit_and_loss_navigation_ext.filter6 Top Hierarchy Level: profit_and_loss_navigation_ext.filter7 Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 @@ -178,8 +178,8 @@ listens_to_filters: [] field: profit_and_loss.target_currency_tcurr - - name: Company - title: Company + - name: Company Code + title: Company Code type: field_filter default_value: "%CENTRAL%" allow_multiple_values: true diff --git a/views/balance_sheet_navigation_ext.view.lkml b/views/balance_sheet_navigation_ext.view.lkml index a9634246..31dd6bdd 100644 --- a/views/balance_sheet_navigation_ext.view.lkml +++ b/views/balance_sheet_navigation_ext.view.lkml @@ -29,7 +29,7 @@ # filter2 Global Currency Global+Currency # filter3 Hierarchy Hierarchy # filter4 Chart of Accounts Chart+of+Accounts -# filter5 Company Company +# filter5 Company Code Company+Code # filter6 Ledger Name Ledger+Name # filter7 Top Hierarchy Level Top+Hierarchy+Level # @@ -71,7 +71,7 @@ # Global Currency: balance_sheet_navigation_ext.filter2 # Hierarchy: balance_sheet_navigation_ext.filter3 # Chart of Accounts: balance_sheet_navigation_ext.filter4 -# Company: balance_sheet_navigation_ext.filter5 +# Company Code: balance_sheet_navigation_ext.filter5 # Ledger Name: balance_sheet_navigation_ext.filter6 # Top Hierarchy Level: balance_sheet_navigation_ext.filter7 #########################################################} @@ -92,7 +92,7 @@ view: balance_sheet_navigation_ext { hidden: yes type: string # sql: 'filter1|Display+Timeframe' ;; - sql: 'filter1|Fiscal+Period||filter2|Global+Currency||filter3|Hierarchy||filter4|Chart+of+Accounts||filter5|Company||filter6|Ledger+Name||filter7|Top+Hierarchy+Level' ;; + sql: 'filter1|Fiscal+Period||filter2|Global+Currency||filter3|Hierarchy||filter4|Chart+of+Accounts||filter5|Company+Code||filter6|Ledger+Name||filter7|Top+Hierarchy+Level' ;; } parameter: navigation_focus_page { @@ -136,7 +136,7 @@ view: balance_sheet_navigation_ext { filter: filter5 { hidden: yes type: string - label: "Company" + label: "Company Code" } filter: filter6 { diff --git a/views/common_fields_finance_ext.view.lkml b/views/common_fields_finance_ext.view.lkml index d47edac3..b4b30961 100644 --- a/views/common_fields_finance_ext.view.lkml +++ b/views/common_fields_finance_ext.view.lkml @@ -60,12 +60,12 @@ view: common_fields_finance_ext { } dimension: company_code { - label: "Company (code)" + label: "Company Code" description: "Company Code" } dimension: company_text { - label: "Company (text)" + label: "Company Code Text" description: "Company Name" } diff --git a/views/navigation_template.view.lkml b/views/navigation_template.view.lkml index 5eadcce9..ddeecba7 100644 --- a/views/navigation_template.view.lkml +++ b/views/navigation_template.view.lkml @@ -79,7 +79,7 @@ # Display Timeframe: profit_and_loss_navigation_ext.filter2 # Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 # Global Currency: profit_and_loss_navigation_ext.filter4 -# Company: profit_and_loss_navigation_ext.filter5 +# Company Code: profit_and_loss_navigation_ext.filter5 # Ledger Name: profit_and_loss_navigation_ext.filter6 # Top Hierarchy Level to Display: profit_and_loss_navigation_ext.filter7 # Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 @@ -309,4 +309,4 @@ view: navigation_template { } -} +} \ No newline at end of file diff --git a/views/profit_and_loss_navigation_ext.view.lkml b/views/profit_and_loss_navigation_ext.view.lkml index 4247d540..b79fa47a 100644 --- a/views/profit_and_loss_navigation_ext.view.lkml +++ b/views/profit_and_loss_navigation_ext.view.lkml @@ -33,7 +33,7 @@ # filter2 Display Timeframe Display+Timeframe # filter3 Select Fiscal Timeframe Select+Fiscal+Timeframe # filter4 Global Currency Global+Currency -# filter5 Company Company +# filter5 Company Code Company+Code # filter6 Ledger Name Ledger+Name # filter7 Top Hierarchy Level to Display Top+Hierarchy+Level+to+Display # filter8 Combine Selected Timeframes? Combine+Selected+Timeframes%3F @@ -80,7 +80,7 @@ # Display Timeframe: profit_and_loss_navigation_ext.filter2 # Select Fiscal Timeframe: profit_and_loss_navigation_ext.filter3 # Global Currency: profit_and_loss_navigation_ext.filter4 -# Company: profit_and_loss_navigation_ext.filter5 +# Company Code: profit_and_loss_navigation_ext.filter5 # Ledger Name: profit_and_loss_navigation_ext.filter6 # Top Hierarchy Level to Display: profit_and_loss_navigation_ext.filter7 # Combine Selected Timeframes?: profit_and_loss_navigation_ext.filter8 @@ -111,7 +111,7 @@ view: profit_and_loss_navigation_ext { hidden: yes type: string # sql: 'filter1|Display+Timeframe' ;; - sql: 'filter1|Hierarchy||filter2|Display+Timeframe||filter3|Select+Fiscal+Timeframe||filter4|Global+Currency||filter5|Company||filter6|Ledger+Name||filter7|Top+Hierarchy+Level||filter8|Combine+Selected+Timeframes%3F' ;; + sql: 'filter1|Hierarchy||filter2|Display+Timeframe||filter3|Select+Fiscal+Timeframe||filter4|Global+Currency||filter5|Company+Code||filter6|Ledger+Name||filter7|Top+Hierarchy+Level||filter8|Combine+Selected+Timeframes%3F' ;; } parameter: navigation_focus_page { @@ -155,7 +155,7 @@ view: profit_and_loss_navigation_ext { filter: filter5 { hidden: yes type: string - label: "Company" + label: "Company Code" } filter: filter6 {