How can I remove rows I don't want after applying a dynamic filter?

I have created the following parameter to use as a dynamic filter: The user can select the best 3, 2 or 1st category that fits into a topic.

### This parameter will allow a user to select a Top N ranking limit
  parameter: top_rank_limit {
    view_label: " Top N Ranking"
    type: unquoted
    default_value: "3"
    allowed_value: {
      label: "Best 3 categories"
      value: "3"
    }
    allowed_value: {
      label: "Best category"
      value: "1"
    }
    allowed_value: {
      label: "Best 2 categories"
      value: "2"
    }
  }
  dimension: category_name_top_categories {
    view_label: " Top N Ranking"
    label: "Categories (Top {% if top_rank_limit._is_filtered %}{% parameter top_rank_limit %}{% else %}N{% endif %})"
    order_by_field: category_rank_top_categories
    type: string
    sql:
      CASE
        WHEN ${category_rank}<={% parameter top_rank_limit %} THEN ${category_name}
      END
    ;;


  }
  dimension: category_rank_top_categories {
    hidden: yes
    label_from_parameter: top_rank_limit
    type: string
    sql:
      CASE
        WHEN ${category_rank}<={% parameter top_rank_limit %}
          THEN
            CASE
              WHEN ${category_rank}<10 THEN  CONCAT('0', CAST(${category_rank} AS STRING))
              ELSE CAST(${category_rank} AS STRING)
            END
      END
    ;;
  }
}

When I select top 3:

ce451947-0740-4d1b-9834-c6e3c963b42f.png

How can I edit the above code (bigquery) so that the rows that aren’t in the top N dont’ appear in the results?

Thanks,

Sarah

0 0 537
0 REPLIES 0
Top Labels in this Space
Top Solution Authors