Forum Discussion
slicer to exclude from table
- 2 years ago
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 !!
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 !!
- darb19852 years agoNew Member
Would you mind providing a pbix file for me to see? I guesss I don;t understand how the filter will be dynamic for the DAX in point 1, these values will be typed by the end user, so its not fixed 😞
I will mark your answer as solution, even though I am not sure how to implement it yet.
- johnbasha332 years agoSuper User
darb1985 Hi, thanks for accepting it. can you provide your pbix file with some sample data? i will implement the solution and will send it back to you.
- darb19852 years agoNew Member
I get the data from Business Central. but it should look something like this:
Item:
id name
1 Datensicherung - Rücksicherung
2 Datensicherung - Externe AufbewahrungInvoice:
id customerName
1 Customer 1
2 Customer 2
InvoiceLines:
invioceId itemId
1 1
1 2
2 2
So if the user searches for 'Datensicherung', the results would be 'Customer 1' and 'Customer 2', now on an additional filter, the user searches for 'Rücksicherung', this one is expected to show the customer that do NOT have that, in this case 'Customer 2'.