  view: store_rank_bi_accounting_by_revenue_selected_months {
    derived_table: {
      sql: select
        storeid
      , sum(client_net_receipt_usd) as store_total_net_for_selected_months
      , sum(units) as store_total_units_for_selected_months
      , rank() over (order by sum(client_net_receipt_usd) desc) as store_rank_for_selected_months
      from prod.bi.accounting ACC
      where {% condition rank_date_filter %} ACC.accounting_month {% endcondition %}
        AND {% condition rank_isrc_filter %} ACC.isrc {% endcondition %}
        AND {% condition rank_upc_filter %} acc.releaseid {% endcondition %}
        AND {% condition rank_artistid_filter %} ACC.artist_id {% endcondition %}
        AND {% condition rank_labelid_filter %} ACC.labelid {% endcondition %}
        AND {% condition rank_storeid_filter %} ACC.storeid {% endcondition %}
        AND {% condition rank_genre_filter %} ACC.release_genre {% endcondition %}
        AND {% condition rank_country_code_filter %} ACC.country_code {% endcondition %}
        AND {% condition rank_continent_filter %} ACC.continent {% endcondition %}
        AND {% condition rank_region_group_filter %} ACC.region_group {% endcondition %}
        AND {% condition rank_transac_type_abbr_filter %} ACC.transac_type_abbr {% endcondition %}
      group by 1
       ;;
    }

    filter: rank_date_filter {
      label: "Accounting Date Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: date
    }
    filter: rank_isrc_filter {
      label: "ISRC Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_upc_filter {
      label: "UPC Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_labelid_filter {
      label: "Label ID Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: number
    }
    filter: rank_artistid_filter {
      label: "Artist ID Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: number
    }
    filter: rank_storeid_filter {
      label: "Store ID Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: number
    }
    filter: rank_genre_filter {
      label: "Genre Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_country_code_filter {
      label: "Country Code Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_continent_filter {
      label: "Continent Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_region_group_filter {
      label: "Region Group Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }
    filter: rank_transac_type_abbr_filter {
      label: "Transaction Type Filter - Store Ranking"
      view_label: "Xtra Advanced Fields"
      type: string
    }

    dimension: store_id_ranking {
      view_label: "Xtra Advanced Fields"
      sql: ${TABLE}.storeid ;;
      type: number
      hidden:  yes
      primary_key: yes
    }

    dimension: store_total_net_for_selected_months {
      view_label: "Xtra Advanced Fields"
      label: "Store Total Net for Selected Months - Store Ranking"
      sql: ${TABLE}.store_total_net_for_selected_months ;;
      type: number
      value_format: "$ #,##0"
    }

    dimension: store_total_units_for_selected_months {
      view_label: "Xtra Advanced Fields"
      label: "Store Total Units for selected_months - Store Ranking"
      sql: ${TABLE}.store_total_units_for_selected_months ;;
      type: number
      value_format: "#,##0"
    }

    dimension: store_rank_for_selected_months {
      view_label: "Xtra Advanced Fields"
      label: "Store Rank for Selected Months - Store Ranking"
      sql: ${TABLE}.store_rank_for_selected_months ;;
      type: number
    }

 }
