Forum Discussion
Using two Distinct Count of fields in a matrix
- 4 years ago
In this scenario, its essence is to count according to the combination of cat and dog. However, the matrix cannot combine people with different ids, so you need to create a measure. In matrix, measure cannot be put in Rows (see picture below). So it needs to create a dimension table first.
(1) create a dimension table
(2) create a measure
Count of Owner IDs = CALCULATE ( DISTINCTCOUNT ( 'Table'[owner_id] ), FILTER ( ALL ( 'Table' ), CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[owner_id] ), 'Table'[species_id] = 1 ) ) = MIN ( 'dimension table'[Dog] ) && CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[owner_id] ), 'Table'[species_id] = 2 ) ) = MIN ( 'dimension table'[Cat] ) ) )result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
In this scenario, its essence is to count according to the combination of cat and dog. However, the matrix cannot combine people with different ids, so you need to create a measure. In matrix, measure cannot be put in Rows (see picture below). So it needs to create a dimension table first.
(1) create a dimension table
(2) create a measure
Count of Owner IDs =
CALCULATE (
DISTINCTCOUNT ( 'Table'[owner_id] ),
FILTER (
ALL ( 'Table' ),
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[owner_id] ), 'Table'[species_id] = 1 )
)
= MIN ( 'dimension table'[Dog] )
&& CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[owner_id] ), 'Table'[species_id] = 2 )
)
= MIN ( 'dimension table'[Cat] )
)
)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
- MPetramalo2144 years agoHelper I
This worked perfectly. Thank you!