Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
StuartSmith
Power Participant
Power Participant

Filter Buttons

I have a report and one section of the report includes a table displaying comments and then a "Text Filter" visual to allow users to search the comments.  

 

The report owner has now asked as well as the search box, would it be possible to have buttons with "Key Words" that will will filter the column table, such as "Huawei" and when the user presses the button, the table displays all rows with "Huawei" in it.

 

2020-12-18_16-02-37.png

 

I will be searching and testing, but any advise/guideance would be grateful.

 

Thanks

 

2 ACCEPTED SOLUTIONS

@StuartSmith  To use the filter, you need to create a measure that connects it to your data, so for example: 

 

SuggestedFilter = IF( CONTAINSSTRING( Table[Comments], SELECTEDVALUE(Slicer[SlicerColumn])) , 1, 0)

 

Then add this slicer to your table visual (and search box too if you want) and set to filter for only = 1 . 

 

Note, this will only work for single selections in the chiclet. You may need more advanced DAX if it must work for multi-select.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

Think i figured it out...

 

TEST_Key_Search_Word_Filter_Measure =
VAR Key_Word = SELECTEDVALUE('Key Words'[Value])
RETURN IF(CONTAINSSTRING(SELECTEDVALUE('Carrier Matrix'[OData__2_Contractcomments]),Key_Word),1,0)
 
Does that look right?

View solution in original post

9 REPLIES 9

Thanks, I am already using that visual, highlighted in "Red", but was hoping for a "Quick Filter" button (Green). 

2020-12-18_17-13-46.png

 

I could use BookMarks, but Bookmarks dont keep filters if set and I know there is a tick box called "Data" to stop filters resetting, but was wondering if you could apply a single word filter to a button.

@StuartSmith Bookmarks 'data' tick box will enable all filters to be saved if ticked, or do nothing with filters if unticked. So if you untick data then you won't be able to apply any filters. 

 

I think the best option is to create a table with the list of words you want users to be able to select. Put that in a slicer (format as horizontal or use chiclet slicer to make them buttons). Then use CONTAINSSTRING to create a measure that filters the table visual when user selects one of those values. Does that make sense?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thanks, I had got as far as getting the "SELECTEDVALUE" displaying in a card and was then going to figure out where to go from there. 

 

I have tried your suggestion, but the "CONTAINSSTRING" parameter only displays existing measures and if I enter the table/column manually, I get the red squiggly error line.  Any ideas why?

 

2020-12-23_09-16-16.png

Think i figured it out...

 

TEST_Key_Search_Word_Filter_Measure =
VAR Key_Word = SELECTEDVALUE('Key Words'[Value])
RETURN IF(CONTAINSSTRING(SELECTEDVALUE('Carrier Matrix'[OData__2_Contractcomments]),Key_Word),1,0)
 
Does that look right?

Thanks, I like the Chiclet visual and have installed.  Also created a table with with a single column containing keywords.  Obviously, as the table only contains 1 column, there is no relationship to filter the other tables.  You mention as measure to filter the report?

 

What the visual needs is another value field, that you could add a table column that the filter buttons filters.

@StuartSmith  To use the filter, you need to create a measure that connects it to your data, so for example: 

 

SuggestedFilter = IF( CONTAINSSTRING( Table[Comments], SELECTEDVALUE(Slicer[SlicerColumn])) , 1, 0)

 

Then add this slicer to your table visual (and search box too if you want) and set to filter for only = 1 . 

 

Note, this will only work for single selections in the chiclet. You may need more advanced DAX if it must work for multi-select.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thanks for your assistance.  I actually developed your response work perfectly on the below thread, but without your assistance, would have struggled.

 

https://community.powerbi.com/t5/Desktop/Develop-existing-Filter-Code/m-p/1586221

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.