The formulas of the course
DAX Cases
40 cases in 5 themes, with 143 traps explained.
A long formula is only a set of pieces fitted together, pieces the lessons have already shown you. Here, you watch it being built piece by piece, and you become familiar with writing complex formulas. Each case reads in four stages, the strategy, the reading, the step by step, then the traps, with the result and the numbers at every step.
A small story behind the name: we almost called this part “the forensic examiner”, because here we dissect formulas.
You have not marked any of the 40 cases as understood yet.
The right denominator, the one that follows the selection, the one that keeps the sort column, the one that compares two years.
- A customer’s Pareto classHow can I sort customers into A, B or C, based on their running share of revenue, from the largest customer to the smallest?
- How far a city stands from the average of the othersBy how much does each city’s revenue differ from the average of the other cities, as a percentage of that average?
- A customer’s weight within the city, compared with the city’s own weightDoes each customer weigh more or less within their city than their city weighs in the total?
- Each city’s share of the total’s growthWhat part of the growth in total revenue, between last year and this year, comes from each city?
- Each month’s share of revenueWhat share of the revenue of all months does each month represent?
- A row’s share of the row that contains itIn a “City” then “Customer” matrix, what share of its parent does each row represent? A customer is compared with its city, and a city with the total.
- The base 100 index on the first month with salesFor each brand and each month, what is the revenue compared with its first month of sales, which counts as 100?
- How far the top customer leads the secondWithin each model type, by how much does the best customer lead the second one, as a percentage of the type’s revenue?
Periods that slide, dates with no sale, rows that do not group the way you expect.
- The moving average of the last three months with salesOn each row, what is the average revenue of the last three months that have sales, up to the month of the row?
- This year’s running total against last year’sEach month, by what proportion does the running total since January beat last year’s running total at the same date?
- The revenue of the last month with salesWhat does each brand sell during the month of its very last sale, from the first to the last day of that month?
- Revenue ordered but not yet deliveredHow much revenue, ordered before the end of each quarter, only gets delivered afterward?
- The month’s share of the last twelve monthsWhat share of the revenue of the last twelve months does each month stand for, provided those twelve months all exist?
- The monthly running total that starts again from zero each yearHow can you accumulate revenue from the first month of each year without using a date function?
- Revenue up to this monthWhat is the revenue of each month that has already begun, with a 0 when the month has no sales?
- The period of each weekHow can you display the dates of the first and last day of each week, and nothing on the other rows?
Which filter stays, which one goes, which one is added. CALCULATE, KEEPFILTERS and TREATAS at work.
- Revenue from SUV customersHow much revenue does each brand make from the customers who bought at least one SUV, whatever the model?
- Revenue outside the selectionHow much revenue does each brand make in the cities the slicer leaves out, with a blank answer when no city is left out?
- Achievement of the brands behind targetFor each year, what share of the target is achieved, keeping only the brands that did not reach it?
- The models only this customer buysHow many models has each customer bought that nobody else has bought?
- Revenue from companies in the USHow much revenue do the companies of New York and Chicago generate, while respecting the customer type the visual shows?
- The target filtered with no relationship to the calendarHow can I show the target for each brand and each year of the visual, when Calendar is not linked to the “Targets” table?
- The dominant city-category pairsFor each category, how much revenue comes from the city-category pairs that do better than the average pair?
- What a model’s buyers spend on the other modelsFor each model, how much did its buyers spend on all the other models?
Adding up, ranking, keeping the best. The formula goes through a table that it builds itself.
- The running total by customerFor each customer, what is the revenue of all the customers who sell at least as much?
- The average of the ranking neighborsFor each customer, what is the average revenue of its ranking trio, made up of the customer itself, the one ranked just above and the one ranked just below?
- A customer’s rank within its city, by cars boughtWhere does each customer stand among the customers of its city, by number of cars bought, written as “2 of 3”?
- The share of revenue outside the top 3 customersIn each city, what share of revenue does not come from the 3 best customers of the whole table?
- A month’s rank within its year, with no tiesWhere does each month stand within its year, from the largest revenue to the smallest, without ever a tie?
- The model that takes the cars sold past 80%In each city, starting from the best-selling model, which model brings the number of cars sold up to 80% of the total?
- Places gained or lost in the ranking of car buyersHow many places does each customer gain or lose between 2024 and 2025 in the ranking by cars bought, with “New” when it bought nothing in 2024?
- How far a model trails the best of its brandFor each model, how far does its revenue trail the best model of the same brand, as a percentage of that best model?
The row context comes into play. A measure called inside an iteration turns each row into a filter.
- A bracket bonus, one customer after anotherWhat is the total of the customers’ bonuses, knowing that the rate depends on their revenue and that a bonus never goes above 30,000?
- Customers above the average of their cityHow many customers beat the average of the customers in their own city?
- The customer with the highest average price in each cityIn each city, which customer pays the most for their cars on average, and how can I show that customer’s name followed by this average price?
- The simple average price and the weighted average priceFor sales at 25,000 or more, by how much does the simple average price exceed the average price weighted by quantity?
- The net amount after two discounts, sale by saleWhat total do I get if I take 3% off each sale made to a company, plus 0.5% for each car sold?
- The average of averages against the average of salesHow far does the average of each customer’s average purchase stray from the average of all the sales?
- How much customers focus on a single modelWhat proportion of their purchases does each customer devote to their main model, and what is the average of these proportions?
- The share of revenue that comes from loyal customersWhat share of the year’s revenue comes from customers who bought at least twice, counting every year?