Forum Discussion
DAX - Distinct Count on zero value from table
Hi and thank you for your reply, I have inserted the below which is very similiar to my solution and have pretty similar results
But when I insert the dax into my card I get a massively inflated value, as you can visually count the answer should be 13 as there are only 13 that have zero
If this does not work, it means something else is at play here. But you're not showing everything that's essential. DAX output depends heavily on the model and the relationships between tables. Therefore the same formula can return different results if the underlying data model is different. I wrote the measure with assumptions that may be wrong in this particular instance. You'll have to either show the model, or - better still - give us a link to a shared file with some example data. Then one can with certainty tell you where it's gone wrong. Otherwise, it's a mere guessing.
- ajaydavidluke4 years ago
Helper I
Sure thing, let me explain a bit more about the relationship as the data is simple:
We have 2 brands within the same warehouse so I have extracted the data from 2 seperate databases and exported them to excel.
The link between the 2 in this instance is the Location. Location Planner WA development is the main table and the Location Planner GA WA development shares the same locations.
I have created a a column which pulls in the value from GA table
-GA Stock Qty = RELATED('Location Planner GA WA development'[DL Stock Qty])-I then add the 2 values together:Total stock qty = 'Location Planner WA development'[DL Stock Qty] + 'Location Planner WA development'[GA Stock Qty]and this is then refrenced in the final zero calculation as sugessted:Empty WA Locations =COUNTROWS(FILTER(DISTINCT( 'Location Planner WA development'[Location] ),'Location Planner WA development'[Total stock qty] = 0))