Loading
Feature Disruption - Service Cloud VoiceRead More
Feature degradation | Gmail Email delivery failureRead More
About Salesforce Data 360
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Formulas in Calculated Fields

          Formulas in Calculated Fields

          A formula tells the Tableau Semantics Query Generator how to calculate the fields when running queries. You can add logic on how to calculate raw data within the dimension or measure.

          Formulas are the core of calculated fields. Calculated fields have additional settings, such as data type and field type, but what makes one calculated field different from another is the formula.

          A calculated field contains a formula, and the formula almost always contains at least one function. These terms—calculation, formula, function—are sometimes used interchangeably, but the’re all distinct concepts. Tableau Semantics formulas are based on Tableau Classic's calculation syntax. For more information on the syntax, see Writing Calculations in Tableau.

          There are four basic components to a formula's syntax:

          • Functions: Statements used to transform the values or members in a field. For more information on functions, see Functions for Calculated Field Formulas.

            Functions require arguments, or specific pieces of information. Depending on the function, arguments can be fields, literals, parameters, or nested functions.
          • Fields: Dimensions or measures from your data source. Field names are surrounded by square brackets [] if they contain spaces, and may include dotted notation to indicate what data object they're from.
          • Operators: Symbols for an operation, such as +, =, and OR.
          • Literal expressions: Constant values that are hardcoded, such as "High" or 1,500.

          Not all formulas contain all these components. Formulas can also contain parameters—placeholder or dynamic values—and comments.

          For example, consider a semantic model for scheduling pets at a vet's office. There's a date field for Initial Visit but you want a calculated field to automatically find the date for a two-week followed. Use the formula:

          DATEADD('day', 14, [Initial Visit])

          Which can be broken down as:

          • Function: DATEADD, which requires three arguments.
            • date_part ('day')

            • interval (14)

            • date ([Initial Visit]).

          • Field: [Initial Visit]

          • Operators: n/a

          • Literal expressions:
            • String literal: 'day'

            • Numeric literal: 14

          In this example, the hardcoded constant 14 can be replaced with a parameter, which allows the user to select how many days out to look for a followup appointment.

          DATEADD('day', [How many days out?], [Initial Visit])

          • Write a Formula in a Calculated Field
            Formulas define how a calculated field is computed. How a formula is written is called its syntax. A formula may contain functions, fields, operators, literal expressions, parameters, or comments.
           
          Loading
          Salesforce Help | Article