[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[],[],null,["# Query result variables let you insert data directly into text elements. For example, you could add text that describes a data point to your report, and then include that data point in the text as a chip. A query result chip updates its value when fresh data is available.\n\nCreate a query result variable\n------------------------------\n\nTo create a query result variable, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. [Add text to your report](/looker/docs/studio/add-text-images-lines-and-shapes-to-your-reports), or edit an existing text element.\n3. Enter `@` to open the variable insert menu.\n4. Click **Add a variable** to open the **Create variable** dialog.\n5. Give your variable a unique name.\n6. In the **Data Source** section, select the data source that the query should start from.\n7. Create a query that returns the data point you'd like to display.\n - You can add or remove dimensions in the **Dimension** section.\n - You can change or remove the selected metric in the **Metric** section. You can select up to one metric.\n - You can add or remove filters in the **Filters** section.\n - You can change the sorting of the table in the **Sort** section.\n8. In the **Column** and **Row** fields, enter the column and row that contain the data point that you'd like to return. You can also click directly on a cell in the data table to select it.\n9. Optionally, edit the **Font color** and **Background color** settings of the query result chip. The **Preview** section displays how the chip will look. You can also apply [conditional formatting](#conditional-formatting) to the chip.\n10. Click **Save**.\n\nLooker Studio inserts the query result chip into the text element. Whenever a user views this text element, the data value is updated.\n\nApply conditional formatting to a query result variable\n-------------------------------------------------------\n\nTo make it easier to visualize and interpret key insights, you can apply conditional formatting that is based on specified rules to highlight data in your query result variables.\n\nTo apply conditional formatting, click **Conditional formatting** when you create or edit a variable. Then select one of the following options in the **Color type** section:\n\n- Select [**Single color**](#single-color) to apply color rules to the query results variable when specific criteria are met.\n- Select [**Color scale**](#color-scale) to color the query results variable by using a gradient of colors that is based on the chip's value.\n\nNote that you can't apply conditional formatting from the **Text Properties** panel while editing text.\n\n### Single color conditional formatting\n\nTo apply single color formatting to a query result variable, follow these steps:\n\n1. In the **Format rules** section, define a format rule.\n - Select the **field** whose value you want to check.\n - Choose a **condition** (for example, GREATER THAN, LESS THAN, EQUAL TO).\n - Enter an **Input value**. This value can also be another field.\n - You can add more `OR` or `AND` conditions to the format rule as needed.\n2. In the **Color and style** section, set the font color and background color that Looker Studio should apply to the query results variable when it meets the format rules.\n\nYou can create multiple format rules with distinct color and style settings.\n\n### Color scale conditional formatting\n\nTo apply a color scale to a query result variable, follow these steps:\n\n1. In the **Format based on** section, select the metric to which you want to apply the color scale.\n2. In the **Color and style** section, select a color scale. You can also click **Reverse color scale** to reverse the color scale.\n3. Select some **Point** values to define the colors at the start and end of your color scale. You can add and delete points to define midpoints along your color scale.\n - You must define at least two points, but you can define up to five points.\n4. Click **Save** to apply your conditional formatting rules.\n\n### Edit and manage conditional formatting rules\n\nTo see all format rules that are applied to a query result variable, click **X rules applied**. Looker Studio displays a list of all format rules that are being applied in a numerical list.\n\nYou can edit, delete, or reorder format rules.\n\nA format rule with a greater numerical list value takes precedent over previous format rules in the list. For example, if your first format rule applies a blue background color if a value is greater than 0, and your second format rule applies a red background color if a value is greater than 1, and the value is greater than both 0 and 1, then Looker Studio will apply a red background color.\n\nEdit and manage query result variables\n--------------------------------------\n\nTo edit a query result variable directly from a report page, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. Select the text field containing the variable, then click the variable.\n3. Click the **Edit variable** icon.\n4. Make any changes to the query or format of the query result variable.\n5. Click **Save**.\n\nTo edit a query result variable from a list of all variables, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. Click the **Resource** menu, and then select **Manage variables (parameters)**.\n3. Next to the query result variable that you'd like to edit, click **Edit**.\n4. Make any changes to the query or format of the variable.\n5. Click **Save**.\n\nDuplicate a query result variable\n---------------------------------\n\nTo duplicate a query result variable, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. Click the **Resource** menu, and then select **Manage variables (parameters)**.\n3. Next to the query result variable that you'd like to duplicate, click **Duplicate**.\n4. Make any changes to the query or format of the variable.\n5. Click **Save**.\n\nDelete a query result variable\n------------------------------\n\nTo delete a query result variable directly from a report page, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. Click or hold the pointer over the query result chip, and then click the **Delete** icon.\n\nTo delete a query result variable from a list of all variables, follow these steps:\n\n1. [Edit your report](/looker/docs/studio/edit-a-report).\n2. Click the **Resource** menu, and then select **Manage variables (parameters)**.\n3. Next to the query result variable that you'd like to delete, click **Delete**.\n4. In the confirmation dialog, click **Remove variable**.\n\nRelated resources\n-----------------\n\n- [Parameters](/looker/docs/studio/parameters)\n- [Add text, images, lines, and shapes to your reports](/looker/docs/studio/add-text-images-lines-and-shapes-to-your-reports)"]]