Power BI lesson
Counting in DAX
18 orders in total. Notice it takes a table name, Sales, not a column. Split by store, Lagos had 9 and Abuja 9.
Try this lesson free →Example
COUNTROWS counts the rows in a table. Each row in Sales is one order:
Orders = COUNTROWS(Sales)Key points
COUNTROWS(Sales)How many rows in the table. Give it a table, not a column.
DISTINCTCOUNT(Sales[ProductID])How many different values in a column: 5 products.
Which one?Counting orders: COUNTROWS. Counting different things: DISTINCTCOUNT.
Eighteen sales, but only five different products: COUNTROWS gives 18, DISTINCTCOUNT(Sales[ProductID]) gives 5.
In Power BI Desktop
New measure, the same way as before. Start typing COUNT in the formula bar and Power BI lists every counting function.
Practice
1. Build the formula for Orders: count the rows in Sales.
Orders = COUNTROWS(Sales)2. Build the formula for the number of different products sold.
Products Sold = DISTINCTCOUNT(Sales[ProductID])3. Write a measure that counts the orders.
Orders = COUNTROWS(Sales)4. Write a measure for the number of different stores.
Stores = DISTINCTCOUNT(Sales[Store])5. Write a measure for the number of different products sold.
Products Sold = DISTINCTCOUNT(Sales[ProductID])Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.
Try this lesson free →