examples/python/create_dashboard_filter.py
def update_elements_filters(element: DashboardElement, filter: DashboardFilter) -> None:
    """Updates a dashboard element's result maker to include a listener on the new dashboard filter.


    Args:
        element (DashboardElement): Dashboard element to update with the new filter
        filter (DashboardFilter): Dashboard filter the element will listen to
    """
    # Keep track of the current result_maker and add to it, otherwise listeners for other filters would be removed
    current_filterables = element.result_maker.filterables
    element.result_maker.filterables = []
    for filterable in current_filterables:
        new_listens = filterable.listen

        # Add listener for new filter, if model and explore is the same
        # You can easily add further restrictions to what tiles or queries within merged results will listen to the new tile
        # If you don't want to restrict what tiles or queries this listen to this filter, just remove this if
        if filter.model == filterable.model and filter.explore == filterable.view:
            new_listens.append(models.ResultMakerFilterablesListen(dashboard_filter_name=filter.name, field=filter.dimension))
            filterable.listen = new_listens
        # Append the new filterables to a result maker that we can use for the dashboard element
        element.result_maker.filterables.append(
                models.ResultMakerFilterables(
                model=filterable.model,
                view=filterable.view,
                listen=new_listens,
                )
            )
    
    # Update element with the new result maker that listens to new filter
    sdk.update_dashboard_element(dashboard_element_id = element.id, body = models.WriteDashboardElement(result_maker = element.result_maker))
Updates a dashboard element's result maker to include a listener on the new dashboard filter.


    Args:
        element (DashboardElement): Dashboard element to update with the new filter
        filter (DashboardFilter): Dashboard filter the element will listen to
    
Updates a dashboard element's result maker to include a listener on the new dashboard filter.
Updates a dashboard element ' s result maker to include a listener on the new dashboard filter .
def update_elements_filters(element: DashboardElement, filter: DashboardFilter) -> None:
    current_filterables = element.result_maker.filterables
    element.result_maker.filterables = []
    for filterable in current_filterables:
        new_listens = filterable.listen
        if filter.model == filterable.model and filter.explore == filterable.view:
            new_listens.append(models.ResultMakerFilterablesListen(dashboard_filter_name=filter.name, field=filter.dimension))
            filterable.listen = new_listens
        element.result_maker.filterables.append(
                models.ResultMakerFilterables(
                model=filterable.model,
                view=filterable.view,
                listen=new_listens,
                )
            )
    sdk.update_dashboard_element(dashboard_element_id = element.id, body = models.WriteDashboardElement(result_maker = element.result_maker))
def update_elements_filters ( element : DashboardElement , filter : DashboardFilter ) -> None : current_filterables = element . result_maker . filterables element . result_maker . filterables = [ ] for filterable in current_filterables : new_listens = filterable . listen if filter . model == filterable . model and filter . explore == filterable . view : new_listens . append ( models . ResultMakerFilterablesListen ( dashboard_filter_name = filter . name , field = filter . dimension ) ) filterable . listen = new_listens element . result_maker . filterables . append ( models . ResultMakerFilterables ( model = filterable . model , view = filterable . view , listen = new_listens , ) ) sdk . update_dashboard_element ( dashboard_element_id = element . id , body = models . WriteDashboardElement ( result_maker = element . result_maker ) )
Updates a dashboard element's result maker to include a listener on the new dashboard filter.
Updates a dashboard element ' s result maker to include a listener on the new dashboard filter .
"""Updates a dashboard element's result maker to include a listener on the new dashboard filter.


    Args:
        element (DashboardElement): Dashboard element to update with the new filter
        filter (DashboardFilter): Dashboard filter the element will listen to
    """ # Keep track of the current result_maker and add to it, otherwise listeners for other filters would be removed # Add listener for new filter, if model and explore is the same # You can easily add further restrictions to what tiles or queries within merged results will listen to the new tile # If you don't want to restrict what tiles or queries this listen to this filter, just remove this if # Append the new filterables to a result maker that we can use for the dashboard element # Update element with the new result maker that listens to new filter
element
DashboardElement
Dashboard element to update with the new filter
Dashboard element to update with the new filter
filter
DashboardFilter
Dashboard filter the element will listen to
Dashboard filter the element will listen to