[[["容易理解","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-09-05 (世界標準時間)。"],[],[],null,["# rand\n\nThe `rand` function can be used in [custom filters](/looker/docs/filtering-and-limiting#custom-filters) and [table calculations](/looker/docs/table-calculations) to return a random number between 0 and 1.\n\nSyntax\n------\n\n**`rand()`**\n\nThe `rand` function returns a random number between 0 and 1.\n\nExamples\n--------\n\nThe `rand` function is often used to generate random integers, sometimes to select a random sampling of data. For example, to generate an integer between 1 and 100 (inclusive) you could use: \n\n (floor(rand()*100)+1)\n\nThis expression works as follows:\n\n1. Uses the `rand()` function to generate a random number between 0 and 1.\n2. Multiplies by 100 to turn it into a random number between 1 and 100.\n3. Uses the [`floor`](/looker/docs/functions-and-operators#function-floor) function to round down the random number to the nearest integer, producing a random number between 0 and 99 (inclusive).\n4. Adds 1 to bring the random integer up to 1 to 100 (inclusive).\n\nYou could then filter your query to only include data below a certain random number.\n\nThings to know\n--------------\n\nThe `rand` function produces a number with 16 decimal places, such as 0.04277424614631747."]]