Data Types & Variables in DAX
Data Types
- DAX is strongly typed language.
- DAX data types can be categorized into three groups:
- Numeric
- Numeric data types include
- Decimal
- Fixed decimal/currency
- Integer/whole numbers,
- Percentage (same is decimal data type but with formatting as percentage)
- Date/Time (underneath Date/Time value is stored as a Decimal Number)
- Date (same as Date/Time value with zero decimal numbers)
- Time (same as Date/Time value with no digits to the left of the decimal place)
- True/False
- Non-numeric
- Non-numeric types include
- Text
- Binary
- Variant
- Variant data type is used for expressions that might return different data types, depending on the conditions.
Variables
- Variables are defined with the VAR keyword and the RETURN clause is used to return a value of the variable.
- Variable should be named using one word; variables can’t contain spaces.
- Variable scope begins with a VAR statement and ends with a matching RETURN statement.
- Once the value of a variable is evaluated, it remains constant and does not change. This behavior is similar to constants in traditional programming languages.
- Variables in DAX are executed within the context of the initial filter and row contexts.
- Use of variables help in simplifying the DAX expressions.
- DAX performs automatic conversion between strings and numbers whenever necessary.
- The following example uses the Sample-Superstore dataset to demonstrate the use of variables in measure Test Variables.
0 comments:
Post a Comment