Forum Discussion
get counts based on nested conditions
- Anonymous2 years ago
Hi, Anonymous
Thank you very much for your reply. Using the following DAX expression will get a count of different IDs:
Count Customer = VAR _seleted_product = SELECTCOLUMNS ( 'Table', 'Table'[Product] ) VAR _table = FILTER ( 'Table', 'Table'[Product] IN _seleted_product ) VAR _ID_AB = SUMMARIZE ( FILTER ( ALL ( 'Table' ), 'Table'[Product] IN { "A", "B" } ), 'Table'[Customer number] ) RETURN IF ( ISFILTERED ( 'Table'[Product] ), COUNTAX ( SUMMARIZE ( FILTER ( _table, 'Table'[Customer number] IN _ID_AB ), 'Table'[Customer number] ), 'Table'[Customer number] ) )Here are the results:
I've uploaded the PBIX file below for your reference.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is good. However, if I select A, B and F, it should return 2 as there are only two unique customer
Hi, Anonymous
Thank you very much for your reply. Using the following DAX expression will get a count of different IDs:
Count Customer =
VAR _seleted_product =
SELECTCOLUMNS ( 'Table', 'Table'[Product] )
VAR _table =
FILTER ( 'Table', 'Table'[Product] IN _seleted_product )
VAR _ID_AB =
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[Product] IN { "A", "B" } ),
'Table'[Customer number]
)
RETURN
IF (
ISFILTERED ( 'Table'[Product] ),
COUNTAX (
SUMMARIZE (
FILTER ( _table, 'Table'[Customer number] IN _ID_AB ),
'Table'[Customer number]
),
'Table'[Customer number]
)
)
Here are the results:
I've uploaded the PBIX file below for your reference.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.