Count customers who grew: compare two columns with ADDCOLUMNS
Add this year’s and last year’s sales to a customer table, then count the customers whose sales went up year over year.
You will learn to
- Add two measure columns to a virtual table
- Compare columns of the same row inside FILTER
- Exclude rows with no history using ISBLANK
How it works
ADDCOLUMNS can add several columns at once: `ADDCOLUMNS(table, "A", expr1, "B", expr2)`. Each row then carries two numbers you can compare side by side.
`FILTER` over that table sees one row at a time, so a condition like `[A] > [B]` compares the two columns **of the same row**. That is how you count “customers whose sales went up”: build the customer table with both years, keep the rows that grew, count them.
Watch the blanks. A customer with no sales last year has a blank in the last-year column, and any sales are “greater than” blank. Decide what you mean: here, a customer with no history isn’t growing, they’re new, so exclude them with `NOT ISBLANK(…)`.
Practice it hands-on with a real data model and a live report that updates as you type.
Products Selling More Units =
VAR P = ADDCOLUMNS(VALUES(Product[Product]), "Now", [Total Quantity], "Before", CALCULATE([Total Quantity], DATEADD('Date'[Date], -1, YEAR)))
RETURN COUNTROWS(FILTER(P, [Now] > [Before]))