Question

Where to get values for filters.

  • 11 May 2021
  • 5 replies
  • 134 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


5 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 ?

>» element_query_body['filters'] 

 

This does not seem to be where they are stored, maybe it was at one time but no longer seem accessible from there.  This property has always shown empty for me regardless of how the filters were set. 

 

Also, just flipping the selector for “tiles to update” etc. (through the api) for these filters seems to be unintuitive.   It appears that is tied to the listeners under result_maker.filterables but any attempt to update them fails.  I have an open case with Looker so hopefully we can get to the bottom of both of these soon.  

Reply