Count only published nodes with taxonomy term
You need to add a Filter Criteria on the view, and choose Content: Published as the criteria, and Yes as the value. This also needs to use the (node) relationship. 

See /* Filter criterion: Content: Published */ on this code. Or import it and look under "Filter Criteria"

$view = new view;
$view-&gt;name = 'Taxtest';
$view-&gt;description = 'Displays node count values for terms';
$view-&gt;tag = '';
$view-&gt;base_table = 'taxonomy_term_data';
$view-&gt;human_name = 'term_node_count';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view-&gt;new_display('default', 'Defaults', 'default');
$handler-&gt;display-&gt;display_options['use_ajax'] = TRUE;
$handler-&gt;display-&gt;display_options['group_by'] = TRUE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'none';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['query']['options']['query_comment'] = FALSE;
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '100';
$handler-&gt;display-&gt;display_options['pager']['options']['offset'] = '0';
$handler-&gt;display-&gt;display_options['pager']['options']['id'] = '0';
$handler-&gt;display-&gt;display_options['pager']['options']['expose']['items_per_page_options_all'] = 0;
$handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
$handler-&gt;display-&gt;display_options['style_options']['columns'] = array(
  'name' =&gt; 'name',
  'nid' =&gt; 'nid',
);
$handler-&gt;display-&gt;display_options['style_options']['default'] = '-1';
$handler-&gt;display-&gt;display_options['style_options']['info'] = array(
  'name' =&gt; array(
    'sortable' =&gt; 0,
    'default_sort_order' =&gt; 'asc',
    'align' =&gt; '',
    'separator' =&gt; '',
  ),
  'nid' =&gt; array(
    'sortable' =&gt; 0,
    'default_sort_order' =&gt; 'asc',
    'align' =&gt; '',
    'separator' =&gt; '',
  ),
);
$handler-&gt;display-&gt;display_options['style_options']['override'] = 1;
$handler-&gt;display-&gt;display_options['style_options']['sticky'] = 0;
/* Relationship: Taxonomy term: Content with term */
$handler-&gt;display-&gt;display_options['relationships']['nid']['id'] = 'nid';
$handler-&gt;display-&gt;display_options['relationships']['nid']['table'] = 'taxonomy_index';
$handler-&gt;display-&gt;display_options['relationships']['nid']['field'] = 'nid';
$handler-&gt;display-&gt;display_options['relationships']['nid']['required'] = 0;
/* Field: Taxonomy term: Name */
$handler-&gt;display-&gt;display_options['fields']['name']['id'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler-&gt;display-&gt;display_options['fields']['name']['field'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['alter_text'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['make_link'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['absolute'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['word_boundary'] = 1;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['ellipsis'] = 1;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['strip_tags'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['trim'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['alter']['html'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['element_label_colon'] = 1;
$handler-&gt;display-&gt;display_options['fields']['name']['element_default_classes'] = 1;
$handler-&gt;display-&gt;display_options['fields']['name']['hide_empty'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['empty_zero'] = 0;
$handler-&gt;display-&gt;display_options['fields']['name']['link_to_taxonomy'] = 1;
/* Field: COUNT(Content: Nid) */
$handler-&gt;display-&gt;display_options['fields']['nid']['id'] = 'nid';
$handler-&gt;display-&gt;display_options['fields']['nid']['table'] = 'node';
$handler-&gt;display-&gt;display_options['fields']['nid']['field'] = 'nid';
$handler-&gt;display-&gt;display_options['fields']['nid']['relationship'] = 'nid';
$handler-&gt;display-&gt;display_options['fields']['nid']['group_type'] = 'count';
$handler-&gt;display-&gt;display_options['fields']['nid']['label'] = 'Count';
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['make_link'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['absolute'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['trim'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['alter']['html'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['element_label_colon'] = 1;
$handler-&gt;display-&gt;display_options['fields']['nid']['element_default_classes'] = 1;
$handler-&gt;display-&gt;display_options['fields']['nid']['hide_empty'] = 0;
$handler-&gt;display-&gt;display_options['fields']['nid']['empty_zero'] = 0;
/* Filter criterion: Content: Published */
$handler-&gt;display-&gt;display_options['filters']['status']['id'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['table'] = 'node';
$handler-&gt;display-&gt;display_options['filters']['status']['field'] = 'status';
$handler-&gt;display-&gt;display_options['filters']['status']['relationship'] = 'nid';
$handler-&gt;display-&gt;display_options['filters']['status']['value'] = '1';

/* Display: Block */
$handler = $view-&gt;new_display('block', 'Block', 'block_1');