[[["容易理解","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,["# Why are my fields with division showing up as 0?\n\nIn certain dialects, including Postgres and Redshift, performing a calculation between integers (like dividing counts) will return an integer even if the result would be a decimal in normal math. For example, you might make measures like the following: \n\n```\nmeasure: sold_ratio {\n type: number\n sql: ${sold_count} / ${total_count} ;;\n value_format: \"0.00\" # Number with exactly 2 decimals (1.23)\n}\nmeasure: sold_percent {\n type: number\n sql: 100 * ${sold_count} / ${count} ;;\n value_format: \"0.00\"\n}\n```\n\n\nHowever, when you run the measures in an Explore, the **Sold Ratio** column returns zero, and the **Sold Percent** column does not have its decimal places populated. This is not correct:\n\n\u003cbr /\u003e\n\n\nThe solution: Cast your field as a floating-point number\n--------------------------------------------------------\n\n\nIf the calculation is multiplied by a non-integer, the values will cast as floats, and decimals will be returned as expected. You can multiply the numerator by a decimal number (like 1.0 or 100.0) to force SQL to return a decimal result: \n\n```\nmeasure: sold_ratio {\n type: number\n sql: 1.0 * ${sold_count} / ${total_count};;\n value_format: \"0.00\"\n}\nmeasure: sold_percent {\n type: Number\n sql: 100.0 * ${sold_count} / ${count};;\n value_format: \"0.00\"\n}\n```\n\n\nThe resulting Explore **Data** table now displays the expected results:\n\n\n\u003cbr /\u003e"]]