Forum Discussion
Distinct count for every customer row
- 5 years ago
Hi Anonymous
I've created the measure but please remember next time not to change the names of the fields in the visual as this makes it really much harder to work with the model for a person that has not worked with the model. Nobody wants to spend time on deciphering step by step, painstakingly, which field belongs to which table.
Here's the measure but I can't guarantee it'll be fast:
The Count = var vCurrentSubjectID = DISTINCT( 'D - Subject'[Subject ID] ) var vResult = if( NOT ISEMPTY( 'F - Sales packing slip' ), CALCULATE( DISTINCTCOUNT( 'F - Sales packing slip'[Packing slip ID] ), 'D - Subject'[Subject ID] in vCurrentSubjectID, ALLSELECTED( 'F - Sales packing slip' ) ) ) return vResult
It's an easy problem but you are not giving us the full picture. Hence the difficulty. How one should write DAX depends heavily on the underlying model. We can't see the model, so... DAX is only a mere guess.
Hi Anonymous, you're right. I was able to upload the file with the data in cloud, you can find it here: https://drive.google.com/file/d/1c6k_mCotPjFSzj1vAgrRT97w2UqRwRW4/view?usp=sharing
What I would like to do is to distinct count the field "Documento di trasporto" for each "Nome" in the time period selected on the upper time filter.
What I expect is the value 4 for COMEK SRL, 1 for F.R. ENGINEERING SRL and 14 for SACMI VERONA SPA