DAX (Data Analysis Expressions):
- Purpose: Used mainly for calculations and data manipulation within Power BI, Power Pivot, and Analysis Services.
- Syntax: Similar to Excel formulas, making it somewhat easier for those familiar with Excel.
- Use Cases: Creating calculated columns, measures, and custom tables.
- Example: Creating a measure to calculate total sales:
Total Sales = SUM(Sales[Amount])
.
M-Code (Power Query Formula Language):
- Purpose: Used for data transformation and ETL (Extract, Transform, Load) processes within Power Query.
- Syntax: Functional language, which can be a bit more complex and different from DAX.
- Use Cases: Importing, cleaning, and reshaping data before loading it into Power BI.
- Example: Renaming a column in a table:
Table.RenameColumns(MyTable, {{"OldColumnName", "NewColumnName"}})
.
So, DAX is all about calculations and aggregations, while M-Code is your go-to for data preparation.