0% found this document useful (0 votes)
2 views

DAX syntax best practices

The document outlines best practices for writing DAX syntax, emphasizing the importance of clear naming conventions, consistency, and readability in DAX formulas. It provides guidelines for naming tables, columns, and measures to enhance clarity and collaboration in Power BI projects. Additionally, it highlights formatting techniques to improve code structure and maintainability.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DAX syntax best practices

The document outlines best practices for writing DAX syntax, emphasizing the importance of clear naming conventions, consistency, and readability in DAX formulas. It provides guidelines for naming tables, columns, and measures to enhance clarity and collaboration in Power BI projects. Additionally, it highlights formatting techniques to improve code structure and maintainability.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Calculated columns with DAX

DAX syntax best practices


Please do not copy without permission. © ExploreAI 2023.
Calculated columns with DAX

Mastering DAX syntax

| DAX syntax refers to the rules and conventions used to write DAX formulas. It includes
functions, operators, and expressions that are used to manipulate and aggregate data.

01. The basic syntax of DAX is similar to spreadsheet formulas, with


Basics of DAX additional functions and operators specific to Power BI.

02. Learning how to create effective DAX formulas will help us get the most
Why learn DAX syntax? out of our data to solve real business problems that affect our bottom line.

Whether a beginner or an experienced user, everyone using DAX should


03. adhere to these guidelines to enhance the clarity and robustness of oneʼs
Who should use DAX guidelines? Power BI projects.

2
Calculated columns with DAX

Mastering DAX syntax


C D

Measure_name = Function_name(Table_name[Column_name])

A B E F

Parentheses surround an expression that


A The measure name. D
contains one or more arguments.

The equal sign indicates the beginning of the


B The referenced table. E
formula. When calculated, it will return a result.

C The DAX function to be used, for example, SUM. The referenced column. F

3
Calculated columns with DAX

DAX syntax best practices


01. Use clear and descriptive naming

● When naming tables, columns, measures, or Do: clear and descriptive naming
variables, choose names that clearly convey the
purpose or content.
Indicator_type =
RIGHT('Indicator'[Indicator_ID], 2)
● Opt for a naming convention that aligns with your == "EQ"
project and team standards.

● Always avoid generic names or abbreviations that Donʼt: generic names and abbreviations
may lead to confusion.

Column_7 =
RIGHT( 'Data_1'[IID], 2 ) == "EQ"

4
Calculated columns with DAX

DAX syntax best practices


02. Consistent naming conventions_ Naming rules

● Consistency should be applied across all 01. Within a single database all tables must have
elements, including tables, columns, measures, unique names.
and variables within your DAX formulas. 02. The names of the columns within each table
must be unique:
● Adopting a standardised approach to naming a. Columns in different tables may possess
ensures that anyone working on the project can the same names.
quickly interpret and navigate the codebase. b. When the same column name is referenced
from two or more tables, we must use a
● This practice promotes collaboration, reduces fully qualified name – that is, the
errors, and enhances the overall maintainability 'Table_name' followed by the
of our Power BI solution. [Column_name].
03. All objects (tables, columns, and measures) are
case insensitive. For instance, the names
‘DATE TABLEʼ and ‘Date Tableʼ would represent
the same table.
5
Calculated columns with DAX

DAX syntax best practices


03. Format and indentation

● Insert spaces around Do: readable


operators to enhance code
readability. Combined_indicator_ID =
IF(
● Use tabs to clearly indicate 'Indicator'[Indicator_gender] == BLANK(),
the hierarchy of nested 'Indicator'[Indicator_ID],
"Male or female"
functions and improve code )
structure.
● When a function call has
multiple arguments, use
Donʼt: poor readability
carriage returns to separate
them. This improves the
Combined_indicator_ID=
overall readability.
IF('Indicator'[Indicator_gender]==BLANK(),'Indicator'[Indicat
or_ID],"Male or female")

You might also like