Home Ask Login Register

Developers Planet

Your answer is one click away!

RunW February 2016

How to count orders with condition A and B in dax

I have a table with order number and product code. One order can have multiple lines. I would like to count the number of orders which have BOTH product code A AND product code B.

My table looks like this:

OrderNumber ProductCode
Order1      A
Order1      B
Order2      B
Order3      A
Order3      B
Order4      C

So for this result set, the answer would be 2, as both Order1 and Order3 contains both A and B.

I would very much like to create this as a measure in dax.

Thank you.


GregGalloway February 2016

Try this:

   MyTable[ProductCode] = "A"
  IF(CALCULATE(COUNTROWS(MyTable),MyTable[ProductCode] = "B") > 0,1)

Post Status

Asked in February 2016
Viewed 3,064 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life