Find the most common value (mode) with ADDCOLUMNS and TOPN
DAX has no MODE function: count each value with ADDCOLUMNS, keep the most frequent with TOPN, and read it back with MAXX.
You will learn to
- Build a frequency table with ADDCOLUMNS
- Keep the most frequent row with TOPN
- Handle ties deliberately
How it works
The **mode** is the value that occurs most often. DAX has no MODE function, but virtual tables make one in three steps:
- `VALUES(Sales[Quantity])` lists the distinct quantities in view (1, 2, 3, 4); - `ADDCOLUMNS` adds how many order lines have each quantity, with a measure so context transition counts each value separately; - `TOPN(1, …, [count column])` keeps the most frequent row.
TOPN returns **all** tied rows, so “top 1” can be two rows. To get one number back, read the column with `MAXX` (the larger tied value) or `MINX` (the smaller). Pick one on purpose and say so in your report. `Sales[Quantity]` keeps its lineage in the table, so you can read it by its full name.
Practice it hands-on with a real data model and a live report that updates as you type.
Most Common Discount =
MAXX(TOPN(1, ADDCOLUMNS(VALUES(Sales[Discount]), "Units", [Total Quantity]), [Units]), Sales[Discount])