Forum Discussion

OpenRoad's avatar
OpenRoad
New Member
9 years ago

Filter Dataset by Secondary Column Only

I'm trying to figure out how to filter a dataset to by a secondary column only.

In Excel the non-optimal workaround is to have two slicers (eg. one for store and one for product and after selecting the store, set the second slicer to select multiple and use a shift click to multi-select all the products then remove the store slicer. In PowerBI the shift click method does not work and the number of products is too large to quickly select by clicking on individually. How can I set it up to filter the dataset by a secondary column only?

For example:

 

Data Table  
   
StoreProductSales
Steve's AutoTires10
Steve's AutoOil4
Rachael's AutoTires9
Rachael's AutoBrakes12
Jeff's AutoBrakes4
Jeff's AutoOil3
   
   
Slicer1  
Steve's Auto<-- Selected Steve's Auto
Rachael's Auto  
Jeff's Auto  
   
   
Resulting Table (Products Steve's Auto Sells)
   
StoreProductSales
Steve's AutoTires10
Steve's AutoOil4
Rachael's AutoTires9
Jeff's AutoOil3

 

Thanks!

4 Replies

  • So far I've been able to still return the total number of Product Sales for all Store's while only showing products for the selected store by using Measure = Calculate(sum(Table[Sales]),all(Table[Stores])) but have not been able to have the other relevant Stores appear in the table.

  • Also, attempts to use a ALL command on the 'store' column have been met with data type errors.

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

     

    Hi, OpenRoad

     

    You could not achieve your goal if you do this in one table. Creating another table would make this easier.

    1. Create a new table with only stores. (Copy the table, keep just column STORE, delete duplicates. )

    2. Delete the relationship if Power BI creates it automatically.

    3. Create a measure like this.

    Measure =
    IF (
        HASONEVALUE ( 'DataTable2'[Store] ),
        IF (
            MIN ( 'DataTable'[Product] )
                IN CALCULATETABLE (
                    VALUES ( 'DataTable'[Product] ),
                    FILTER (
                        ALL ( 'DataTable' ),
                        'DataTable'[Store] = VALUES ( DataTable2[Store] )
                    )
                ),
            "y",
            BLANK ()
        ),
        0
    )

     

    Hope this would be a little help.