SELECT * ,  count(distinct id) over (partition by country_id) as count_country_level
FROM `fao-maps.fao_digital_villages_portfolio.vw_digital_portfolio_detail_lat_lon` 
WHERE (@countries = "all" or country_id = @countries) and 
      (
        @digital_innovation_themes = "all" or 
        regexp_contains( digital_innovation_theme_id ,concat('([^0-9]|^)',@digital_innovation_themes,'([^0-9]|$)'))
      ) and 
      (
        @business_themes = "all" or 
       regexp_contains( business_theme_id ,concat('([^0-9]|^)',@business_themes,'([^0-9]|$)')) 
      ) 
      group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17