---
schema_version: "1"
id: e190dc4bca6299fcf59c3b84f80f965066d77051864c30f0fbb1b199be5d4922
title: 创建简单的计算字段
collection: tableau
version: current
locale: zh-cn
portal_url: https://docs.salesforce.com/tableau/current/zh-cn/public/desktop/calculations_calculatedfields_formulas.md
canonical_url: https://help.tableau.com/current/public/desktop/zh-cn/calculations_calculatedfields_formulas.htm
source_site: help.tableau.com
content_type: documentation
content_hash: da35b6f0f63b5672f9c6a5fa0ef36aa0e4fa219b80d196b1cdb44fb96acbdae9
description: Create a simple calculated field, such as Profit Ratio, using a formula from existing fields.
---
[跳转到主要内容](#main-content)

# 创建简单的计算字段

有时，您的数据源不包含分析所需要的字段（或列）。例如，您的数据源可能包含带有“Sales”（销售额）和“Profit”（利润）值的字段，但不包括带有“Profit Ratio”（利润率）值的字段。如果是这种情况，您可以使用“Sales”（销售额）和“Profit”（利润）字段中的数据为“Profit Ratio”（利润率）创建一个计算字段。

本主题说明如何使用示例创建简单的计算字段。

## 步骤 1：创建计算字段

1. 在 Tableau 内的工作表中，选择“分析”\>“创建计算字段”。
2. 在打开的计算编辑器中，为此计算字段指定一个名称。在本示例中，该计算字段称为**“Profit Ratio”**（利润率）。

## 步骤 2：输入公式

1. 在计算编辑器中，输入以下公式：
    
    SUM(\[Profit\])/SUM(\[Sales\])
    
    公式使用函数、字段和运算符的组合。要了解有关在 Tableau 中创建公式的详细信息，请参阅[在 Tableau 中编写计算](https://help.tableau.com/current/public/desktop/zh-cn/functions_operators.htm)和[Tableau 中的函数](https://help.tableau.com/current/public/desktop/zh-cn/functions.htm)。
2. 完成后，单击**“确定”**。新的计算字段将添加到“数据”窗格，并在数据类型图标前面带有 = 来指示它是计算字段。

您现在可以在视图中使用计算字段。

## 检查您的工作！观看如何在操作过程中创建一个简单的计算字段：

## 另请参见

[Tableau 中的计算入门指南](https://help.tableau.com/current/public/desktop/zh-cn/calculations_calculatedfields_create.htm)

[在 Tableau 中编写计算](https://help.tableau.com/current/public/desktop/zh-cn/functions_operators.htm)

[Tableau 中的函数](https://help.tableau.com/current/public/desktop/zh-cn/functions.htm)

[在 Tableau 中创建详细级别表达式](https://help.tableau.com/current/public/desktop/zh-cn/calculations_calculatedfields_lod.htm)

[使用表计算转换值](https://help.tableau.com/current/public/desktop/zh-cn/calculations_tablecalculations.htm)