Forum Discussion
akwang
8 years agoAdvocate II
Countif DAX
Hi I have a table with a column for order status which could either be "on time" or "delayed". I want to create a MEASURE for Total Orders delayed that will tell me how much orders were delayed. In e...
- Anonymous8 years ago
CALCULATE and FILTER are the first two things you need to learn about DAX.
Measure = CALCULATE( COUNT(TableName[Column That Identifies Unique Orders]), FILTER( TableName, TableName[Delay Status] = "On Time" || TableName[Delay Status] = "Delayed" ) )
mede
8 years agoResolver I
You need to familiarize yourself with DAX logic:
This will give you count of On Time orders:
Count of On Time Orders = CALCULATE(DISTINCTCOUNT(TableName[order_id]),TableName[Delay Status] = "On Time" )
in plain english: Calculate the distinctcount of order_ids where delay status is "on time"
This will give you count of Fulfilled AND On Time orders
Count of Fulfilled On Time Orders = CALCULATE(DISTINCTCOUNT(TableName[order_id]),TableName[Delay Status] = "On Time", TableName[Short Ship Status] = "Fulfilled")
- Anonymous8 years agoNot applicable
medecareful with that shortcut syntax. It includes an implicit ALL() clause that can cause unexpected results if you don't know what you're doing with it. Can be dangerous to suggest to beginners. I prefer to always use explicit FILTER() statements to avoid this.