Forum Discussion
DAX code filtering tabled based on selected value (show other values)
- Anonymous2 years ago
Hi,Anne_PBI .Thank you for your reply.
Here is my latest code.DIM_Items_02 = DISTINCT(SELECTCOLUMNS('Table', "Item02", 'Table'[Item], "Customer",'Table'[Customer])) test_result = CALCULATE( COUNTROWS('Table'), FILTER( 'Table', 'Table'[Item] <> SELECTEDVALUE(DIM_Items_02[Item02]) && 'Table'[Customer] IN CALCULATETABLE( VALUES('DIM_Items_02'[Customer]), 'Table'[Item] = SELECTEDVALUE(DIM_Items_02[Item02]) ) ) )
The previous version I gave you would have filtered out the same type of food by default, now the newest code meets your existing needs and hopefully helps!I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
many thanks for your help! It works for the food items but unfortunately not yet for the drink items. I cannot figure out why it doesn't work as you only filter based on the item and not the type. Do you have any ideas?
Based on the selection of fries, this would be result I would expect:
or condensed:
Kind regards,
Anne
Hi,Anne_PBI .Thank you for your reply.
Here is my latest code.
DIM_Items_02 = DISTINCT(SELECTCOLUMNS('Table', "Item02", 'Table'[Item], "Customer",'Table'[Customer]))
test_result =
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[Item] <> SELECTEDVALUE(DIM_Items_02[Item02]) &&
'Table'[Customer] IN
CALCULATETABLE(
VALUES('DIM_Items_02'[Customer]),
'Table'[Item] = SELECTEDVALUE(DIM_Items_02[Item02])
)
)
)
The previous version I gave you would have filtered out the same type of food by default, now the newest code meets your existing needs and hopefully helps!
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.