Forum Discussion

Anne_PBI's avatar
Anne_PBI
Frequent Visitor
2 years ago
Solved

DAX code filtering tabled based on selected value (show other values)

Hi all,   I have an issues to which I cannot find the solution. I hope someone can help me out. I've created an example dataset to explain the problem: customers order food and drinks in a restaura...
  • Anonymous's avatar
    Anonymous
    2 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.