Question

Where to get values for filters.

  • 11 May 2021
  • 4 replies
  • 81 views

When I get a dashboard from the API and its list of filters, I would like to then make a subsequent call to get the values for those filters. I have not been able to find the correct query to return the appropriate values. When I look in the developer tab for the built in filters, all of the calls are for “internal” endpoints, and those do not translate to the API


4 replies

Userlevel 3

You have to iterate through `dashboard_element`. There should be a set of filters parameters in the response body (which object would be would depend on the specific tile). For example this would be along the lines of how you could get the first tile of a given dashboard’s filters if the tile has this stored in the `result_maker` object:

 

import looker_sdk
sdk = looker_sdk.init31("looker.ini")

data = sdk.search_dashboard_elements(dashboard_id=dash_id)

element_query_body = data[0].result_maker.query

element_query_body['filters']

 

You have to iterate through `dashboard_element`. There should be a set of filters parameters in the response body (which object would be would depend on the specific tile). For example this would be along the lines of how you could get the first tile of a given dashboard’s filters if the tile has this stored in the `result_maker` object:

 

import looker_sdk
sdk = looker_sdk.init31("looker.ini")

data = sdk.search_dashboard_elements(dashboard_id=dash_id)

element_query_body = data[0].result_maker.query

element_query_body['filters']

 

 

I guess I was making this harder on myself trying to use the API without the SDK. I will give that a go and see if it makes my life any easier, thanks.

Hello @jamesnestler ,

 

When I run the code:
 

import looker_sdk
sdk = looker_sdk.init31("looker.ini")

data = sdk.search_dashboard_elements(dashboard_id=dash_id)

element_query_body = data[0].result_maker.query

element_query_body['filters']

 

I get “None”, why would it be? Any ideas?

 

Thanks,
Ranjit

import looker_sdk

sdk = looker_sdk.init31("looker.ini")

data = sdk.search_dashboard_elements(dashboard_id=dash_id)

element_query_body = data[0].result_maker.query element_query_body['filters']

 

I am getting NULL. Can anyone help ?

Reply