 
   dashboard_value: =>
     return null unless @app.settings.merit_order_enabled()
-    q = @gquery.future_value()
-    profitables = _.select(_.values(q), (v) -> v.profitable == 'profitable' ).length
-    tot = _.keys(q).length
-    profitables/tot
+    total = @total_available_capacity()
+    return null if total == 0
+    @profitable_capacity() / @total_available_capacity()
 
   format_table: =>
     tmpl = _.template $('#merit-order-table-template').html()

    if pa != pb
      return -1 if pa < pb
      return 1 if pa > pb
      return 0
    # sort by descending profits
    return -1 if ca > cb
    return 1 if ca < cb
    return 0

  profitability_index: (x) ->
    switch x.profitable
      when 'profitable' then 0
      when 'conditionally_profitable' then 1
      when 'unprofitable' then 2

  series_labels:
    energy_chp_combined_cycle_network_gas: 'central_gas_chp'
    energy_chp_ultra_supercritical_coal: 'coal_chp'

        profits_per_unit: values.profits_per_unit
        label: @series_labels[key] || key

    sorted_items = items.sort(@sorting_function)
    $('#merit-order-table').html tmpl({series: sorted_items})
    true

  # Sort by two fields
  #
  sorting_function: (a,b) =>
    pa = @profitability_index a
    pb = @profitability_index b
