Bins not working

Is my issue the same as: Histogram bin size not working well ?

50 bins returns one bin per row?

Hi @rviteri
I don't understand. If your problem is the same as the other forum topic, and there's an issue referenced in the end, then what is the question?

Sorry for not being clear about this. I want 50 bins but I get much more than that.

@rviteri Post "Diagnostic Info" from Admin > Troubleshooting.

And you need to provide information about the what exactly "total_ventas" is, so go to Admin > Data Model > (db) > (table) > "total_ventas" :gear: - look in the URL, when ends something like .../123/general.
Now go to the URL /api/field/123 and provide the output here.

This is a custom query.

"total_ventas" is the aggregate sum of a column of a subquery.

The field that is being aggregated comes from the sum of two columns:

Column 1:

{
  "description": null,
  "database_type": "DOUBLE",
  "semantic_type": null,
  "table_id": 36,
  "coercion_strategy": null,
  "table": {
    "description": null,
    "entity_type": "entity/GenericTable",
    "schema": null,
    "show_in_getting_started": false,
    "name": "pagos_detalles",
    "caveats": null,
    "updated_at": "2022-03-08T14:22:11.902218Z",
    "active": true,
    "id": 36,
    "db_id": 2,
    "visibility_type": null,
    "field_order": "database",
    "initial_sync_status": "complete",
    "display_name": "Pagos Detalles",
    "created_at": "2018-08-30T07:33:31.557Z",
    "points_of_interest": null
  },
  "name": "abono",
  "fingerprint_version": 4,
  "has_field_values": "none",
  "settings": null,
  "caveats": null,
  "fk_target_field_id": null,
  "dimensions": [],
  "updated_at": "2021-06-19T03:22:18.612158Z",
  "custom_position": 0,
  "effective_type": "type/Float",
  "active": true,
  "parent_id": null,
  "id": 246,
  "last_analyzed": "2019-05-19T07:00:45.666Z",
  "position": 0,
  "visibility_type": "normal",
  "preview_display": true,
  "display_name": "Abono",
  "database_position": 0,
  "name_field": null,
  "fingerprint": {
    "global": {
      "distinct-count": 778,
      "nil%": 0
    },
    "type": {
      "type/Number": {
        "min": 0,
        "max": 485,
        "avg": 47.60190600000001,
        "sd": 42.15128831993302,
        "q1": 19.373357795336485,
        "q3": 62.39499738863424
      }
    }
  },
  "created_at": "2018-08-30T07:33:50.927Z",
  "base_type": "type/Float",
  "points_of_interest": null
}

Column 2:

{
  "description": null,
  "database_type": "DOUBLE",
  "semantic_type": null,
  "table_id": 36,
  "coercion_strategy": null,
  "table": {
    "description": null,
    "entity_type": "entity/GenericTable",
    "schema": null,
    "show_in_getting_started": false,
    "name": "pagos_detalles",
    "caveats": null,
    "updated_at": "2022-03-08T14:22:11.902218Z",
    "active": true,
    "id": 36,
    "db_id": 2,
    "visibility_type": null,
    "field_order": "database",
    "initial_sync_status": "complete",
    "display_name": "Pagos Detalles",
    "created_at": "2018-08-30T07:33:31.557Z",
    "points_of_interest": null
  },
  "name": "saldo",
  "fingerprint_version": 4,
  "has_field_values": "none",
  "settings": null,
  "caveats": null,
  "fk_target_field_id": null,
  "dimensions": [],
  "updated_at": "2021-06-19T03:22:18.635649Z",
  "custom_position": 0,
  "effective_type": "type/Float",
  "active": true,
  "parent_id": null,
  "id": 241,
  "last_analyzed": "2019-05-19T07:00:45.666Z",
  "position": 0,
  "visibility_type": "normal",
  "preview_display": true,
  "display_name": "Saldo",
  "database_position": 8,
  "name_field": null,
  "fingerprint": {
    "global": {
      "distinct-count": 3739,
      "nil%": 0
    },
    "type": {
      "type/Number": {
        "min": 0,
        "max": 489.45,
        "avg": 51.25305700000001,
        "sd": 43.57489225825833,
        "q1": 21.60927992382739,
        "q3": 65.81451180021715
      }
    }
  },
  "created_at": "2018-08-30T07:33:50.924Z",
  "base_type": "type/Float",
  "points_of_interest": null
}

@rviteri Okay, then I don't think it's getting the fingerprinting data, which is needed to create binning.
https://github.com/metabase/metabase/issues/5594 - upvote by clicking :+1: on the first post

1 Like

Hello, was this issue resolved? I am not sure if I am seeing the same error on V. 0.43.4:

[7d5d02c0-7544-4e7b-9c6f-33b9a156bb67] 2022-07-01T08:22:02-05:00 ERROR metabase.query-processor.middleware.catch-exceptions Error procesando consulta: No se puede agrupar el campo sin un valor mínimo/máximo
{:database_id 2,
 :started_at #t "2022-07-01T08:22:02.372621-05:00[America/Guayaquil]",
 :via
 [{:status :failed,
   :class clojure.lang.ExceptionInfo,
   :error "No se puede agrupar el campo sin un valor mínimo/máximo",
   :stacktrace
   ["--> query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
    "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:47)"
    "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:38)"
    "query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
    "mbql.util.match.impl$replace_in_collection$iter__20130__20134$fn__20135.invoke(impl.cljc:44)"
    "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:43)"
    "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:38)"
    "query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
    "query_processor.middleware.binning$update_binning_strategy_in_inner_query.invokeStatic(binning.clj:214)"
    "query_processor.middleware.binning$update_binning_strategy_in_inner_query.invoke(binning.clj:210)"
    "query_processor.middleware.binning$update_binning_strategy.invokeStatic(binning.clj:228)"
    "query_processor.middleware.binning$update_binning_strategy.invoke(binning.clj:221)"
    "query_processor$preprocess_STAR_$fn__52913.invoke(query_processor.clj:124)"
    "query_processor$preprocess_STAR_.invokeStatic(query_processor.clj:122)"
    "query_processor$preprocess_STAR_.invoke(query_processor.clj:117)"
    "query_processor$fn__52921$combined_pre_process__52922$combined_pre_process_STAR___52923.invoke(query_processor.clj:204)"
    "query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__51368$fn__51373.invoke(resolve_database_and_driver.clj:35)"
    "driver$do_with_driver.invokeStatic(driver.clj:75)"
    "driver$do_with_driver.invoke(driver.clj:71)"
    "query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__51368.invoke(resolve_database_and_driver.clj:34)"
    "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__47473.invoke(fetch_source_query.clj:277)"
    "query_processor.middleware.store$initialize_store$fn__47661$fn__47662.invoke(store.clj:11)"
    "query_processor.store$do_with_store.invokeStatic(store.clj:44)"
    "query_processor.store$do_with_store.invoke(store.clj:38)"
    "query_processor.middleware.store$initialize_store$fn__47661.invoke(store.clj:10)"
    "query_processor.middleware.normalize_query$normalize$fn__51640.invoke(normalize_query.clj:22)"
    "query_processor.middleware.constraints$add_default_userland_constraints$fn__48730.invoke(constraints.clj:53)"
    "query_processor.middleware.process_userland_query$process_userland_query$fn__51579.invoke(process_userland_query.clj:145)"
    "query_processor.middleware.catch_exceptions$catch_exceptions$fn__51951.invoke(catch_exceptions.clj:168)"
    "query_processor.reducible$async_qp$qp_STAR___44200$thunk__44202.invoke(reducible.clj:100)"
    "query_processor.reducible$async_qp$qp_STAR___44200.invoke(reducible.clj:106)"
    "query_processor.reducible$async_qp$qp_STAR___44200.invoke(reducible.clj:91)"
    "query_processor.reducible$sync_qp$qp_STAR___44211.doInvoke(reducible.clj:126)"
    "query_processor$process_userland_query.invokeStatic(query_processor.clj:326)"
    "query_processor$process_userland_query.doInvoke(query_processor.clj:322)"
    "query_processor$fn__52968$process_query_and_save_execution_BANG___52977$fn__52980.invoke(query_processor.clj:337)"
    "query_processor$fn__52968$process_query_and_save_execution_BANG___52977.invoke(query_processor.clj:330)"
    "query_processor$fn__53012$process_query_and_save_with_max_results_constraints_BANG___53021$fn__53024.invoke(query_processor.clj:349)"
    "query_processor$fn__53012$process_query_and_save_with_max_results_constraints_BANG___53021.invoke(query_processor.clj:342)"
    "api.dataset$run_query_async$fn__66704.invoke(dataset.clj:68)"
    "query_processor.streaming$streaming_response_STAR_$fn__39322$fn__39323.invoke(streaming.clj:162)"
    "query_processor.streaming$streaming_response_STAR_$fn__39322.invoke(streaming.clj:161)"
    "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:65)"
    "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:63)"
    "async.streaming_response$do_f_async$task__18948.invoke(streaming_response.clj:84)"],
   :ex-data {:clause [:field "Ventas" {:binning {:strategy :num-bins, :num-bins 50}, :base-type :type/Float}]}}],
 :error_type :invalid-query,
 :json_query
 {:database 2,
  :query
  {:source-table "card__39",
   :filter
   ["and"
    ["!=" ["field" "Ventas" {:base-type "type/Float"}] 0]
    ["time-interval" ["field" "created_at" {:base-type "type/DateTimeWithLocalTZ"}] "current" "month"]],
   :aggregation
   [["cum-sum" ["field" "Ventas" {:base-type "type/Float"}]]
    ["count"]
    ["aggregation-options"
     ["percentile" ["field" "Ventas" {:base-type "type/Float"}] 0.25]
     {:name "25%", :display-name "25%"}]
    ["aggregation-options"
     ["percentile" ["field" "Ventas" {:base-type "type/Float"}] 0.5]
     {:name "50%", :display-name "50%"}]
    ["aggregation-options"
     ["percentile" ["field" "Ventas" {:base-type "type/Float"}] 0.75]
     {:name "75%", :display-name "75%"}]],
   :breakout [["field" "Ventas" {:binning {:strategy "num-bins", :num-bins 50}, :base-type "type/Float"}]]},
  :type "query",
  :parameters [],
  :middleware {:js-int-to-string? true, :add-default-userland-constraints? true}},
 :native nil,
 :status :failed,
 :class clojure.lang.ExceptionInfo,
 :stacktrace
 ["--> query_processor.middleware.binning$fn__40133$extract_bounds__40138$fn__40139.invoke(binning.clj:49)"
  "query_processor.middleware.binning$fn__40133$extract_bounds__40138.invoke(binning.clj:30)"
  "query_processor.middleware.binning$fn__40376$update_binned_field__40381$fn__40394.invoke(binning.clj:197)"
  "query_processor.middleware.binning$fn__40376$update_binned_field__40381.invoke(binning.clj:189)"
  "query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
  "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:47)"
  "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:38)"
  "query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
  "mbql.util.match.impl$replace_in_collection$iter__20130__20134$fn__20135.invoke(impl.cljc:44)"
  "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:43)"
  "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:38)"
  "query_processor.middleware.binning$update_binning_strategy_in_inner_query$replace_40418__40419.invoke(binning.clj:214)"
  "query_processor.middleware.binning$update_binning_strategy_in_inner_query.invokeStatic(binning.clj:214)"
  "query_processor.middleware.binning$update_binning_strategy_in_inner_query.invoke(binning.clj:210)"
  "query_processor.middleware.binning$update_binning_strategy.invokeStatic(binning.clj:228)"
  "query_processor.middleware.binning$update_binning_strategy.invoke(binning.clj:221)"
  "query_processor$preprocess_STAR_$fn__52913.invoke(query_processor.clj:124)"
  "query_processor$preprocess_STAR_.invokeStatic(query_processor.clj:122)"
  "query_processor$preprocess_STAR_.invoke(query_processor.clj:117)"
  "query_processor$fn__52921$combined_pre_process__52922$combined_pre_process_STAR___52923.invoke(query_processor.clj:204)"
  "query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__51368$fn__51373.invoke(resolve_database_and_driver.clj:35)"
  "driver$do_with_driver.invokeStatic(driver.clj:75)"
  "driver$do_with_driver.invoke(driver.clj:71)"
  "query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__51368.invoke(resolve_database_and_driver.clj:34)"
  "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__47473.invoke(fetch_source_query.clj:277)"
  "query_processor.middleware.store$initialize_store$fn__47661$fn__47662.invoke(store.clj:11)"
  "query_processor.store$do_with_store.invokeStatic(store.clj:44)"
  "query_processor.store$do_with_store.invoke(store.clj:38)"
  "query_processor.middleware.store$initialize_store$fn__47661.invoke(store.clj:10)"
  "query_processor.middleware.normalize_query$normalize$fn__51640.invoke(normalize_query.clj:22)"
  "query_processor.middleware.constraints$add_default_userland_constraints$fn__48730.invoke(constraints.clj:53)"
  "query_processor.middleware.process_userland_query$process_userland_query$fn__51579.invoke(process_userland_query.clj:145)"
  "query_processor.middleware.catch_exceptions$catch_exceptions$fn__51951.invoke(catch_exceptions.clj:168)"
  "query_processor.reducible$async_qp$qp_STAR___44200$thunk__44202.invoke(reducible.clj:100)"
  "query_processor.reducible$async_qp$qp_STAR___44200.invoke(reducible.clj:106)"
  "query_processor.reducible$async_qp$qp_STAR___44200.invoke(reducible.clj:91)"
  "query_processor.reducible$sync_qp$qp_STAR___44211.doInvoke(reducible.clj:126)"
  "query_processor$process_userland_query.invokeStatic(query_processor.clj:326)"
  "query_processor$process_userland_query.doInvoke(query_processor.clj:322)"
  "query_processor$fn__52968$process_query_and_save_execution_BANG___52977$fn__52980.invoke(query_processor.clj:337)"
  "query_processor$fn__52968$process_query_and_save_execution_BANG___52977.invoke(query_processor.clj:330)"
  "query_processor$fn__53012$process_query_and_save_with_max_results_constraints_BANG___53021$fn__53024.invoke(query_processor.clj:349)"
  "query_processor$fn__53012$process_query_and_save_with_max_results_constraints_BANG___53021.invoke(query_processor.clj:342)"
  "api.dataset$run_query_async$fn__66704.invoke(dataset.clj:68)"
  "query_processor.streaming$streaming_response_STAR_$fn__39322$fn__39323.invoke(streaming.clj:162)"
  "query_processor.streaming$streaming_response_STAR_$fn__39322.invoke(streaming.clj:161)"
  "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:65)"
  "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:63)"
  "async.streaming_response$do_f_async$task__18948.invoke(streaming_response.clj:84)"],
 :card_id 39,
 :context :ad-hoc,
 :error "No se puede agrupar el campo sin un valor mínimo/máximo",
 :row_count 0,
 :running_time 0,
 :preprocessed nil,
 :ex-data
 {:type :invalid-query,
  :field-id nil,
  :fingerprint
  {:global {:distinct-count 0, :nil% nil},
   :type {:type/Number {:min nil, :q1 nil, :q3 nil, :max nil, :sd nil, :avg nil}}}},
 :data {:rows [], :cols []}}

@rviteri Sounds like a completely different issue.

Can I split the message into a new post? Or should I repost?

@rviteri Different problems, different topics. And please with context if you want help. If you are looking for an update about a referenced issue, then click the issue, if it is Open, then it's not fixed and I cannot provide a timeline.

1 Like