Forum Discussion

Stevianne's avatar
Stevianne
Frequent Visitor
5 years ago
Solved

advanced filtering

Hello Powerbi community,   I need some help with advanced filtering. I created a small example. When I filter on Bananas I do not only want to see  A, B and D I also want to see A bought 5 peaches...
  • v-yingjl's avatar
    v-yingjl
    5 years ago

    Hi Stevianne ,

    Extract the fruit column as a single calculated table and use it as a the slicer:

    Fruit = DISTINCT('Table'[Fruit])

    Create a measure like this:

    _count = 
    VAR tab =
        FILTER (
            'Table',
            CALCULATE (
                SUM ( 'Table'[Count] ),
                FILTER (
                    ALLEXCEPT ( 'Table', 'Table'[Category] ),
                    'Table'[Fruit] = SELECTEDVALUE ( Fruit[Fruit] )
                )
            ) > 0
        )
    RETURN
        SUMX (
            FILTER (
                tab,
                [Category]
                    IN DISTINCT ( 'Table'[Category] )
                        && [Fruit] IN DISTINCT ( 'Table'[Fruit] )
            ),
            [Count]
        )

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.