view: int_dbt_prod_monthly_territory_kpis {

  derived_table: {
    sql:

    select
      *
    from {% if country_group_type._parameter_value == "'label'" %} intelligence.dbt_prod.monthly_territory_kpis
        {% elsif country_group_type._parameter_value == "'ifpi'" %}  intelligence.dbt_prod.ifpi_monthly_territory_kpis
        {% endif %}
    ;;

  }

  parameter: country_group_type {
    type: string
    allowed_value: { label: "Label Country" value: "label"}
    allowed_value: { label: "IFPI Country Groups" value: "ifpi"}
  }

  dimension: country {
    description: "The country or country group."
    type: string
    sql: ${TABLE}.transaction_country ;;
  }

  dimension_group: activity_month{
    description: "The brand that the label belongs to."
    type: time
    sql: ${TABLE}.activity_month ;;
  }

  measure: country_market_share_local_streams{
    description: ""
    type: average
    sql: ${TABLE}.country_market_share_local_streams ;;
  }

  measure: country_market_share_global_streams{
    description: ""
    type: average
    sql: ${TABLE}.country_market_share_global_streams ;;
  }

  measure: country_market_share_local_revenue{
    description: ""
    type: average
    sql: ${TABLE}.country_market_share_local_revenue ;;
  }

  measure: country_market_share_global_revenue{
    description: ""
    type: average
    sql: ${TABLE}.country_market_share_global_revenue ;;
  }

  measure: local_label_margin {
    description: ""
    type: average
    sql: ${TABLE}.local_label_margin ;;
  }

  measure: orchard_top_store_streams {
    description: ""
    type: sum
    sql: ${TABLE}.orchard_top_store_streams ;;
  }

  measure: orchard_top_stores_local_label_streams {
    description: ""
    type: sum
    sql: ${TABLE}.orchard_top_store_local_label_streams ;;
  }

  measure: orchard_top_stores_global_label_streams {
    description: ""
    type: sum
    sql: ${TABLE}.orchard_top_stores_global_label_streams ;;
  }

  measure: total_market_top_store_streams {
    description: ""
    type: sum
    sql: ${TABLE}.total_market_top_store_streams ;;
  }

  measure: local_label_revenue_outside_home_country {
    description: ""
    type: sum
    sql: ${TABLE}.local_label_revenue_outside_home_country ;;
  }

  measure: world_wide_revenue_from_local_labels {
    description: ""
    type: sum
    sql: ${TABLE}.world_wide_revenue_from_local_labels ;;
  }

  measure: world_wide_distribution_fee_local_label {
    description: ""
    type: sum
    sql: ${TABLE}.world_wide_distribution_fee_local_label ;;
  }

}
