Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Data model & measures lab

Write measures on a small star schema and see filter context at work: totals, CALCULATE, ALL, SUMX and one-way or two-way relationships.

Relationships to Sales:

How to use

  1. Measures: write one measure per line as Name = expression, choose a column for the rows and, if you like, a slicer, then press Work it out. Every cell is worked out on its own, and so is the Total row.
  2. Use Add an example to paste ready-made measures under yours and see what each function does.
  3. Model and filters: pick a filter and see how many rows each table keeps. Switch a relationship to both ways and watch the filter flow back from Sales into that table.
  4. Tables: the four made-up tables behind the lab.

Keyboard and touch

TabMove between the boxes, lists and buttons
EnterOn the Work it out button: run the measures

Tips

  • Look at the Total row for Stores selling: it is 4, not the sum of the rows, because each row and the total are counted in their own filter context.
  • Products shows 8 for every region while the relationships go one way: a filter on Store reaches Sales but does not come back to Product. Switch Product to both ways and the count becomes the products sold in that region.
  • The Airport store has no sales, so Store[Store] = Airport gives blanks, not zeros. Blank plus a number gives the number; blank times a number stays blank.
  • Use DIVIDE instead of / whenever the bottom can be blank or zero; it returns blank (or your third argument) instead of an error.
  • Keep facts (sales lines) in one table and descriptions (product, store, month) in the tables around it. Filters then flow one way, from the descriptions to the facts, and the results are easy to explain.

About this tool

The lab has a star schema of four made-up tables: 72 sales lines, 8 products, 5 stores and 6 months. Each description table has a one-to-many relationship to Sales. The measure language is our own small evaluator, written in the style of the formula languages of business-intelligence tools (such as DAX in Power BI): SUM, AVERAGE, MIN, MAX, DISTINCTCOUNT, COUNTROWS, SUMX, RELATED, DIVIDE, BLANK, CALCULATE with filters such as Product[Category] = "Bikes", and ALL or REMOVEFILTERS on a table or a column. Inside SUMX a measure or CALCULATE turns the current row into a filter (context transition), as those languages do.

It covers only these functions and simple filters, and it does not copy any product. Real tools have many more functions, data types, many-to-many relationships and rules for ambiguous paths. Not affiliated with or endorsed by Microsoft or any other software maker; product names are trademarks of their owners.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product