Forum Discussion

darb1985's avatar
darb1985
New Member
2 years ago
Solved

slicer to exclude from table

Hello,   I hope someone can help with me this problem.    I have a power bi report with three tables:   -Item (ItemID, Name) -invoice (DocumentID, CustomerName) -invoicelines (DocumentID, It...
  • johnbasha33's avatar
    2 years ago

    darb1985 

    To achieve the desired filtering behavior in Power BI, you can use a combination of slicers and measures to filter customers based on the presence or absence of specific items, such as "Service flat rate" and "Data backup." Here's how you can set it up:

    1. **Create Measures**:
    Create measures to identify whether an item is present in an invoice. You can use DAX expressions like COUNTROWS and FILTER to count the occurrences of specific items in the invoicelines table.

    ```DAX
    ServiceFlatRateSold =
    CALCULATE(
    COUNTROWS('invoicelines'),
    FILTER(
    'invoicelines',
    RELATED('Item'[Name]) = "Service flat rate*flat rate*"
    )
    )
    ```

    ```DAX
    DataBackupSold =
    CALCULATE(
    COUNTROWS('invoicelines'),
    FILTER(
    'invoicelines',
    RELATED('Item'[Name]) = "Data backup"
    )
    )
    ```

    2. **Create Customer Filter**:
    Create a new measure to filter customers based on the presence or absence of specific items.

    ```DAX
    FilterCustomers =
    IF(
    [ServiceFlatRateSold] > 0 && [DataBackupSold] = 0,
    1,
    0
    )
    ```

    This measure will return 1 if a customer has purchased the "Service flat rate" item and has not purchased the "Data backup" item.

    3. **Apply Filter**:
    Apply the "FilterCustomers" measure as a visual-level filter in your customer name visual. Set the filter to include only rows where "FilterCustomers" equals 1.

    4. **Add Slicer**:
    Add a slicer for the item names and use it to filter the data based on the items sold.

    With this setup, when you select "Service flat rate*flat rate*" in the slicer, the customer name visual will only display customers who have purchased the "Service flat rate" item and have not purchased the "Data backup" item. Adjust the DAX expressions and filter logic as needed to fit your specific requirements and data model.

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!