[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-31 UTC。"],[],[],null,["# Create a dynamic dashboard image with Liquid and HTML\n\nYou can add images to Looker dashboards by hard-coding an image URL in a Markdown [text tile](/looker/docs/using-markdown-in-text-tiles#images). However, images in text tiles are static and will not update based on results.\nWhat if you want a dashboard image to dynamically change based on a user-selected filter value?\n\n\nThis Best Practices page demonstrates how to achieve a dynamic dashboard image using [Liquid](/looker/docs/liquid-variable-reference) and the [`html` parameter](/looker/docs/reference/param-field-html).\n\nThe solution\n------------\n\n\nThe following solution is based on an e-commerce data set that includes a field called `users.state`, representing the states in a hypothetical ecommerce data set: \n\n```\ndimension: state {\n type: string\n sql: ${TABLE}.state ;;\n}\n```\n\n\nSay that you want to display the image of a state's flag on a dashboard that will update based on the state by which a user chooses to filter the dashboard results.\n\n\nThere are three steps that you need to complete to create the dynamic dashboard image:\n\n1. Create an image dimension in LookML.\n2. Create a dynamic image dashboard tile.\n3. Add dashboard filters and final touches.\n\n\u003cbr /\u003e\n\n### Step 1: Create an image dimension in LookML\n\n\nTo create an image dimension in LookML:\n\n1. First, navigate to the project and view file containing the dimension to which you would like to add images. Then, create a new dimension based on that field, specifically for the use of displaying the images.\n2.\n Add an `html` parameter for defining a Liquid [`{% if %}` conditional statement](/looker/docs/liquid-variable-reference#basic_examples) with the [`value`](/looker/docs/liquid-variable-reference#liquid_variable_definitions) variable, for each value for which you want to display an image.\n\n\n For example, the following `state_flag_image` dimension establishes a condition for displaying the specified images (with `html \u003cimg\u003e `tags) when the value of `state` is `\"California\"`, `\"New York\"`, `\"Colorado\"`, or `\"Illinois\"`. For all other states, you can display a \"no image available\" icon: \n\n ```\n dimension: state_flag_image {\n type: string\n sql: ${state} ;;\n html:\n {% if state._value == \"California\" %}\n \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/0/01/Flag_of_California.svg\" height=\"170\" width=\"255\"\u003e\n {% elsif state._value == \"New York\" %}\n \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Flag_of_New_York.svg/1200px-Flag_of_New_York.svg.png\" height=\"170\" width=\"255\"\u003e\n {% elsif state._value == \"Colorado\" %}\n \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Flag_of_Colorado.svg/255px-Flag_of_Colorado.svg.png\" height=\"170\" width=\"255\"\u003e\n {% elsif state._value == \"Illinois\"%}\n \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Flag_of_Illinois.svg/1200px-Flag_of_Illinois.svg.png\" height=\"170\" width=\"255\"\u003e\n {% else %}\n \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No_image_available.svg/1024px-No_image_available.svg.png\" height=\"170\" width=\"170\"\u003e\n {% endif %} ;;\n }\n \n ```\n3. Create a value condition for each value for which you would like to display an image. Alternatively, you can create a dynamic image field using the `value` Liquid variable, as described in the [How to add images to visualizations](https://community.looker.com/technical-tips-tricks-1021/how-to-add-images-to-visualizations-30238) Community post.\n\n\nNext, you can create a dashboard tile for the image dimension.\n\n### Step 2: Create a dynamic image dashboard tile\n\n\nNow that the image dimension (`state_flag_image`) has been created, you can build an Explore that will become the dynamic image dashboard tile.\n\nBuild your Explore with the following criteria:\n\n- Add a filter for the original dimension (in this case, `state`). Set the filter for any value (the state flag will display the \"no image available\" image in this case, as no specific filter value is selected). This filter value will update according to what the user selects for the dashboard filter.\n- Select the image dimension (in this case, `state_flag_image`) and any other dimensions that may be necessary to the query that determines the image (for example, if you want to factor in a date, you can include date, etc.).\n- Change the [row limit](/looker/docs/filtering-and-limiting#limiting_data) to one row.\n- Change the visualization type to a [single value visualization](/looker/docs/single-value-options) and [hide](/looker/docs/creating-visualizations#specifying_lookml_fields_to_include_in_the_visualization) any other columns except the image dimension (`state_flag_image`).\n\n\nYour Explore will display the first image result in the single value visualization rendered in the **Visualization** panel. The display image will change based on the filter value the user selects on the final dashboard:\n\n\nSave the Explore to a dashboard as a [tile](/looker/docs/creating-user-defined-dashboards#adding_query_tiles_from_an_explore).\n\n### Step 3: Add dashboard filters and final touches\n\n\nNow you need to add dashboard filters to the dashboard. The filters on the dashboard will update the filter in the Explore to change the image displayed based on user selection.\n\n\nFrom the dashboard's edit mode, [create the filter](/looker/docs/filters-user-defined-dashboards#adding_dashboard_filters):\n\n- Open the [**Add filter window**](/looker/docs/filters-user-defined-dashboards#the_add_filter_window)\n- Select the field to filter by. The filter field should be the dimension on which the image dimension is based. In the case of this example, the field for the filter will be **state**.\n- Select the image tile from Step 2 on the **Tiles to Update** tab.\n- Select the original dimension (**state** in this case) in the inline **Field to Filter** drop-down menu.\nSelect other tiles to update as desired.\n- [Customize](/looker/docs/filters-user-defined-dashboards#customizing_filter_configuration) the filter as desired. If you select the **Advanced** [control option](/looker/docs/filters-user-defined-dashboards#using_advanced_controls), make sure to deselect the **Allow multiple filter values** option, which is automatically enabled for the **Advanced** control option.\n\n\nNow, the image tile will update with the user filter selection.\n\n\nWhen a user chooses to filter by \"California\", the dashboard will display the state flag and data for the state of California:\n\n\nWhen a user chooses to filter by \"Colorado\", the dashboard will display the state flag and data for the state of Colorado:"]]