Forum Discussion
SELECTED VALUES IN TABLE
Hi all,
Could you please advice how to fix this issue?
I need to exclude customers that bought at least one of the selected products. My current solution works if you select only one product, however I need to make it work for multiple selection. thanks 🙂
My main table:
Customer IDProduct
| 1 | a |
| 1 | b |
| 1 | c |
| 1 | d |
| 2 | c |
| 2 | d |
| 2 | f |
| 2 | j |
| 3 | j |
| 3 | a |
| 4 | v |
| 4 | c |
| 4 | t |
| 5 | a |
| 5 | d |
| 6 | f |
| 6 | r |
| 6 | d |
slicer disconnected = VALUES(main[Product])Customer concat = SUMMARIZE('main',main[Customer ID])
calculated column in the 'customer concat' table:
Product_Concat =
CONCATENATEX(
FILTER(
'main',
'main'[Customer ID] = 'Customer concat'[Customer ID]),'main'[Product],
" ; ",'main'[Product],
ASC)
Measure :
Products_exclusion =
VAR _customer = SELECTEDVALUE('main'[Customer ID])
VAR _custmomer_products = SUMMARIZE(FILTER('main','main'[Customer ID]=_customer),main[Product])
VAR _selected_products = ALLSELECTED('slicer disconnected'[Product])
RETURN
IF(
ISFILTERED(
'slicer disconnected'[Product]),
IF(
_selected_products IN _custmomer_products,
0,
1
),
1)
This is my main visual that needs to be filtered correctly based on the slicer selection.
data model:
thanks amitchandak . I actually managed to solve it after many hours of thinking! 😄
Products_exclusion = VAR _table = CALCULATETABLE(SUMMARIZE('main','main'[Customer ID]), FILTER(ALL('main'),'main'[Product] IN FILTERS('slicer disconnected'[Product]))) RETURN IF( ISFILTERED( 'slicer disconnected'[Product]), IF( MAX('Customer concat'[Customer ID]) IN _table, 0, 1 ), 1)
3 Replies
- amitchandak
Super User
LWOLF , Make sure independent table for the product is used in slicer, I changed the name to product
try measure
Customer concat =
var _cust = except(all(main[Customer ID]) , SUMMARIZE(filter('main',main[Product] in VALUES(Product[Product])), main[Customer ID]))
return
countrows(filter(main, main[Customer ID] in _cust ))plot this with customer
- LWOLFRegular Visitor
thanks amitchandak . I actually managed to solve it after many hours of thinking! 😄
Products_exclusion = VAR _table = CALCULATETABLE(SUMMARIZE('main','main'[Customer ID]), FILTER(ALL('main'),'main'[Product] IN FILTERS('slicer disconnected'[Product]))) RETURN IF( ISFILTERED( 'slicer disconnected'[Product]), IF( MAX('Customer concat'[Customer ID]) IN _table, 0, 1 ), 1)- amitchandak
Super User
LWOLF , Kudos to You