Forum Discussion

ttpcap's avatar
ttpcap
New Member
6 years ago
Solved

Filtering a table by the same field multiple times

I have a table for Restaurants that is structured as follows: Column 1: Restaurant Name - there 80,000 restaurants all with unique names Column 2: Menu #: I've tracked the first 10 menu items in th...
  • v-juanli-msft's avatar
    6 years ago

    Hi ttpcap 

    1.

    build a simple filter or slicer to show the total number of restaurants that offer both Pizza AND Salad and then then filter that by whether they are profitable or not?

    ->

    Create new tables and create relationships

     

    Item = VALUES('Table'[Menu Item])
    
    Profit/Loss = VALUES('Table'[Profit/Loss])

     

    2.

    what % of Restaurants are profitable when they offer a Sandwhich as Menu #1 and a Salad as Menu #2 vs. those that offer a Main as Menu #1 and a Main as Menu #2, etc etc. 

    for example:  % of  Restaurants are profitable when they offer a Main as Menu #1 and a Sandwhich as Menu #2

    Create two new tables, which doesn't connect to any other table,

    Add columns from the two tables into slicers,

    then create measures

    selected1 = IF(SELECTEDVALUE('Type1'[Item Type])=MAX('Table'[Item Type]),MAX('Table'[Menu #]))
    
    selected2 = IF(SELECTEDVALUE('Type2'[Item Type])=MAX('Table'[Item Type]),MAX('Table'[Menu #]))
    
    Measure =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[estaurant Name] ),
        FILTER (
            'Table',
            (
                (
                    'Table'[Item Type] = SELECTEDVALUE ( 'Type1'[Item Type] )
                        && [selected1] = 1
                )
                    || (
                        'Table'[Item Type] = SELECTEDVALUE ( 'Type2'[Item Type] )
                            && [selected2] = 2
                    )
            )
                && 'Table'[Profit/Loss] = "P"
        )
    )
        / CALCULATE ( DISTINCTCOUNT ( 'Table'[estaurant Name] ), ALLSELECTED ( 'Table' ) )
    

     

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