Map with Field Filters

Hi, I have 4 bar charts and 1 Map that I need to put together in a dashboard. I have written SQL queries with field filters for all the 4 bar charts which is working fine as expected with the pre-populated dropdown values for user input. But with the Map, If i write a SQL query then my Latitude and Longitude does not show up as geographical type to add to the Pin Map and if i make it a model then that problem gets solved bu I cannot use the field filters. My drop down has to filter all the 5 different charts and map on the dashboard. Has anyone faced this before and suggest a solution to get it working? Thanks in advance!

Hi @raj006
Post "Diagnostic Info" from Admin > Troubleshooting.
You should be able to define latitude and longitude - even for SQL questions.

Hi @flamber , Here is the diagnostic info:

{
  "browser-info": {
    "language": "en-US",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "Cp1252",
    "java.runtime.name": "Java(TM) SE Runtime Environment",
    "java.runtime.version": "11.0.16+11-LTS-199",
    "java.vendor": "Oracle Corporation",
    "java.vendor.url": "https://openjdk.java.net/",
    "java.version": "11.0.16",
    "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
    "java.vm.version": "11.0.16+11-LTS-199",
    "os.name": "Windows Server 2019",
    "os.version": "10.0",
    "user.language": "en",
    "user.timezone": "UTC"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "mysql"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "1.4.197 (2018-03-18)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "1.4.197 (2018-03-18)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2022-08-16",
      "tag": "v0.44.1",
      "branch": "release-x.44.x",
      "hash": "112f5aa"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

@flamber When I use the SQL query, Metabase does not even show me the Latitude and Longitude in the dropdown selections:
map_issue

@flamber I don't see an option to set data type for columns based on SQL queries. Please tell me how I can do that. Thanks!

@raj006 You cannot set the data type in SQL unless you're using Models.
I'm guessing that you're not returning numeric/float columns but strings instead.
You should migrate away from H2 if you're using Metabase in production:
https://www.metabase.com/docs/latest/installation-and-operation/migrating-from-h2
Latest release is 0.44.3: https://github.com/metabase/metabase/releases/latest

@flamber This instance is a test one, we have another one for production which is h2.

You said I should be able to define latitude and longitude even for SQL questions right? Could you please help me with that?
Thanks!

@raj006 Include the question metadata by going to /api/card/123, where 123 is the question ID.

Sorry @flamber I am very new to Metabase. Could you please explain in little more detail?
I have a SQL query written in Metabase where I brought Zipcode, Latitude, Longitude and no. of people by zip. If I create a Pin Map using this SQL it does not show me the Latitude and Longitude. When you said include the question by going to /api/card/123, I am not able to get it.

Thanks,

@raj006 Create a question where you're having problems. Save the question. Look in the URL with will be /question/123-blahblah then change the URL to /api/card/123 and include the output here (redact name/email).

It's working fine, when I test, but perhaps you should include your SQL query:

Hi @flamber Thank you for the details. Here is the output:

{"description":null,"archived":false,"collection_position":null,"table_id":null,"result_metadata":[{"display_name":"state","field_ref":["field","state",{"base-type":"type/Text"}],"name":"state","base_type":"type/Text","effective_type":"type/Text","semantic_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":2.0}}}},{"display_name":"zip","field_ref":["field","zip",{"base-type":"type/Text"}],"name":"zip","base_type":"type/Text","effective_type":"type/Text","semantic_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":5.0}}}},{"display_name":"latitude","field_ref":["field","latitude",{"base-type":"type/Text"}],"name":"latitude","base_type":"type/Text","effective_type":"type/Text","semantic_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":1.0}}}},{"display_name":"longitude","field_ref":["field","longitude",{"base-type":"type/Text"}],"name":"longitude","base_type":"type/Text","effective_type":"type/Text","semantic_type":null,"fingerprint":{"global":{"distinct-count":1,"nil%":0.0},"type":{"type/Text":{"percent-json":0.0,"percent-url":0.0,"percent-email":0.0,"percent-state":0.0,"average-length":1.0}}}},0}}}}],"creator":{"email":"rmani@mail.com","first_name":"Raj","last_login":"2022-09-21T20:26:16.492","is_qbnewb":false,"is_superuser":true,"id":1,"last_name":"Mani","date_joined":"2022-08-23T15:40:20.585","common_name":"Raj Mani"},"can_write":true,"database_id":2,"enable_embedding":false,"collection_id":3,"query_type":"native","name":"Map3 - SQL","last_query_start":null,"dashboard_count":0,"average_query_time":null,"creator_id":1,"moderation_reviews":[],"updated_at":"2022-09-28T15:48:06.852","made_public_by_id":null,"embedding_params":null,"cache_ttl":null,"dataset_query":{"type":"native","native":{"query":"personal_owner_id":null,"id":3,"entity_id":"gvn_DWbaP8QyAc1rrLjMk","location":"/1/2/","namespace":null},"parameters":[],"dataset":false,"created_at":"2022-09-28T15:45:32.907","public_uuid":null}

@raj006 Like I guessed initially, your lat/long columns are string, so cast them as float/decimal.
cast(your_latitude_column as decimal) as latitude_decimal

Thank you so much @flamber . It works very well for me now.