---
schema_version: "1"
id: ed52b55d97f2d257bd3def9f6ca3d7e95d935a16f5486a7e96f7814477d03233
title: Best Practices When Writing Formulas
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/c360_a_sl_calc_fields_formula_best_practice.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.c360_a_sl_calc_fields_formula_best_practice.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c91ac0d770fa5dd2e93aeb73eddb891537d7cbaa7508cb08914e5f050bd1e1ad
description: The formula syntax affects the way the formula is queried.
products:
  - Data 360
release: "264"
---
# Best Practices When Writing Formulas

The formula syntax affects the way the formula is queried.

When writing a formula, use these syntax rules.

- Use the correct functions as described in Adding Functions.
- Surround fields in the formula by brackets.
- Use the correct operator syntax
    - +, —, \*, /, %, ==, =, >, <, >=, <=, !=, <>, ^, AND, OR, NOT, ( ).
    - Tableau Semantics uses Tableau operator syntax. See [Tableau Operator syntax documentation.](https://help.tableau.com/current/pro/desktop/en-us/functions_operators.htm#Operators)
- Use the correct literal expression syntax
    - Numeric literal expressions are written as numbers. For example, 1.3567.
    - String literal expressions are written with quotation marks. For example, “Unprofitable”.
    - Date literal expressions are written with the # symbol. For example: #August 22, 2024#.
    - Null literal expressions are written as “null”.
    - Tableau Semantics uses Tableau literal expressions. Learn more about literal expressions in the [Tableau Literal expression syntax documentation](https://help.tableau.com/current/pro/desktop/en-us/functions_operators.htm#literals).
- Use the correct date function syntax:
    
    - Date functions are hardcoded in ISO format:
        - Date: "yyyy—MM—dd" or "yyyymmdd" or "yyyy—MM" OR “yyyy”
        - Time:
            - Hh:mm:ss
            - Hh:mm:ss.sss
            - HH:mm:ss.SSSSSS
            - Hh:mm:ssZZZZ
            - Hh:mm:ssSS.ZZZZZ
            - "T\[hh\]\[mm\]\[ss\]"
            - "T\[hh\]:\[mm\]:\[ss\] "
            - “T\[hh\]:\[mm\]:\[ss\]ZZZZZ”
        - Datetime: "<date>T<time>" or "<date> <time>" or "<date>’T’<time>"
        - Examples:
            
            "2020—02—08T09"
            
            "2020—02—08 09"
            
            "2020—02—08 09:30:26"
            
            "2020—02—08 09:30:26.123"
    
    - Use DATEPARSE for other formats.
- Use the correct comment syntax
    - To enter a comment in a calculation, type two forward slashes: //
    - Multiline comments can be added by typing /\* to start the comment and \*/ to end the comment.
    - Example of a formula with comments:
        
        ```
        SUM([Sales]) / SUM([Profit])
        
        /*John's calculation
        
        To be used for profit ratio
        
        Do not edit*/
        ```