BACK TO BLOG

Power BI - DAX - Common Expressions

This list will be constantly updated with more formulas as and when I use them.

Revenue YTD = TOTALYTD([Total Revenue], 'Date'[Date], ALL('Date'))

Revenue Last Year = CALCULATE([Total Revenue], SAMEPERIODLASTYEAR('Date'[Date]))
OR
Prev Year Total Sales = (SUM([Amount]), SAMEPERIODLASTYEAR('Date'[Date]))


Balance Forward Revenue = OPENINGBALANCEMONTH([Revenue YTD], 'Date'[Date])

Cost Per Minute = AVERAGEX('Movie Values', [Total Budget] / 'Movie Values'[Runtime])
//AVERAGEX is an iterator function which means it performs this operation, Total Budget divided by Runtime, for each row in the specified table, which, in this case, is the Movie Values table. And then after it's done those calculations, it takes the results and averages them.

All Revenue = CALCULATE([Total Revenue], ALL('Movies'))
% of Total Revenue = [Total Revenue] / [All Revenue]

Gross Profit = CALCULATE([Total Revenue] - [Total Cost], FILTER('Table', [Total Cost]>0), FILTER('Table 2', [Total Revenue]>0))

USERELATIONSHIP('Movie Values'[Release Date], 'Date'[Date]))
//You may get an error when trying to activate a relationship between two tables.
//You cannot simultaneously link one query to two fact tables.
//To get around this, the 'USERELATIONSHIP' formula can be used to make the relationship.