Power BI DAX Cheatsheet 🚀
1️⃣ Basics of DAX (Data Analysis Expressions)
DAX is used to create custom calculations in Power BI.
It works with tables and columns, not individual cells.
Functions in DAX are similar to Excel but optimized for relational data.
2️⃣ Aggregation Functions
SUM(ColumnName): Adds all values in a column.
AVERAGE(ColumnName): Finds the mean of values.
MIN(ColumnName): Returns the smallest value.
MAX(ColumnName): Returns the largest value.
COUNT(ColumnName): Counts non-empty values.
COUNTROWS(TableName): Counts rows in a table.
3️⃣ Logical Functions
IF(condition, result_if_true, result_if_false): Conditional statement.
SWITCH(expression, value1, result1, value2, result2, default): Alternative to nested IF.
AND(condition1, condition2): Returns TRUE if both conditions are met.
OR(condition1, condition2): Returns TRUE if either condition is met.
4️⃣ Time Intelligence Functions
TODAY(): Returns the current date.
YEAR(TODAY()): Extracts the year from a date.
TOTALYTD(SUM(Sales[Amount]), Date[Date]): Year-to-date total.
SAMEPERIODLASTYEAR(Date[Date]): Returns values from the same period last year.
DATEADD(Date[Date], -1, MONTH): Shifts dates by a specified interval.
5️⃣ Filtering Functions
FILTER(Table, Condition): Returns a filtered table.
ALL(TableName): Removes all filters from a table.
ALLEXCEPT(TableName, Column1, Column2): Removes all filters except specified columns.
KEEPFILTERS(FilterExpression): Keeps filters applied while using other functions.
6️⃣ Ranking & Row Context Functions
RANKX(Table, Expression, [Value], [Order]): Ranks values in a column.
TOPN(N, Table, OrderByExpression): Returns the top N rows based on an expression.
7️⃣ Iterators (Row-by-Row Calculations)
SUMX(Table, Expression): Iterates over a table and sums calculated values.
AVERAGEX(Table, Expression): Iterates over a table and finds the average.
MAXX(Table, Expression): Finds the maximum value based on an expression.
8️⃣ Relationships & Lookup Functions
RELATED(ColumnName): Fetches a related column from another table.
LOOKUPVALUE(ColumnName, SearchColumn, SearchValue): Returns a value from a column where another column matches a value.
9️⃣ Variables in DAX
VAR variableName = Expression RETURN variableName
Improves performance by reducing redundant calculations.
🔟 Advanced DAX Concepts
Calculated Columns: Created at the column level, stored in the data model.
Measures: Dynamic calculations based on user interactions in Power BI visuals.
Row Context vs. Filter Context: Understanding how DAX applies calculations at different levels.
Free Power BI Resources: https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c
React with ❤️ for free cheatsheets
Share with credits: https://t.me/sqlspecialist
Hope it helps :)
Post #1714
1.56K
- 👍 6
- ❤ 2