[[["容易理解","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 (世界標準時間)。"],[],[],null,["# Creating dynamic tiers\n\nTiers can be a great way to bucket values. However, with LookML [`type: tier`](/looker/docs/reference/param-dimension-filter-parameter-types#tier) dimensions, those buckets are predefined and static. Sometimes you may want to create a dynamic tier that lets users change the bucket size. You can do this in Looker using filter-only fields (called [`parameter` parameters](/looker/docs/reference/param-field-parameter)) in conjunction with a templating language (called [Liquid)](/looker/docs/liquid-variable-reference).\n\n\nYou can also use [custom binning](/looker/docs/custom-fields#custom_binning) to create dynamic tiers natively in Explores when you have [permission to create or edit custom fields](/looker/docs/admin-panel-users-roles#create_custom_fields).\n\n\nTo create a dynamic tier:\n\n1. Create a parameter of `type: number` to serve as the frontend filter field where the user can enter the numerical bucket size they would like.\n2. Create a dimension that references the parameter value with the Liquid variable [`{% parameter parameter_name %}`](/looker/docs/liquid-variable-reference#liquid_variable_definitions). This dimension determines the various buckets and will dynamically change the bucket size to the value entered by the user in the frontend filter field (the `parameter` parameter).\n\n\nFor example, a developer creates a dynamic age tier that lets users bucket age values by custom ranges:\nThe SQL syntax for the following example may need to be adapted to suit your database dialect. \n\n```\n parameter: age_tier_bucket_size {\n type: number\n }\n\n dimension: dynamic_age_tier {\n type: number\n sql: TRUNCATE(${TABLE}.age / {% parameter age_tier_bucket_size %}, 0)\n * {% parameter age_tier_bucket_size %} ;;\n }\n```\n\n\nA user can now choose tier values for the **Age** column in an Explore. For example, a user might want to see ages grouped into 10-year buckets and so enter the value **10** in the **Age Tier Bucket Size** filter:\n\n\nThe SQL expression in the `dynamic_age_tier` dimension divides an age value from the underlying `${TABLE}.age` column --- for example, 25 --- by the parameter value of 10, resulting in 2.5. The value 2.5 is truncated to 2 by the `TRUNCATE` function and is multiplied by the parameter value 10, resulting in 20. 20 becomes the bucket; any age value between 20 and 29 is included in the **20** bucket.\n\n\u003cbr /\u003e"]]