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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
StuartSmith
Power Participant
Power Participant

Develop existing Filter Code

Happy New Year All, I have the below code that searches and filters a table column based on the selected value of another table and it works great, but need to develop it with more functionallity.

 

TEST_Search_SelectValue =
COUNTX (
FILTER ('Key Words', SEARCH ( [Value], SELECTEDVALUE ( 'Carrier Matrix'[OData__2_Contractcomments] ), 1, 0 ) > 0
),
1
)

 

Currently if there is no selected value, everything is filtered and the Carrier Matrix table visual is empty.  Is there a way so that if there is no selected value, no filter is applied and all rows in the "Carrier Matrix" table are displayed. I have tried something like...

 

TEST_Search_SelectValue =
IF(COUNTROWS('Key Words')=1, COUNTX(FILTER('Key Words', SEARCH ( [Value], SELECTEDVALUE ( 'Carrier Matrix'[OData__2_Contractcomments] ), 1, 0 ) > 0
),
1
))
 
and this filters if a Selected Value is present, but still displays an empty table if there no SelectedValue.  How can I fix this?  
Thanks in advance

 

1 ACCEPTED SOLUTION

Got it working with...

 

TEST_Search_SelectValue =
IF (
COUNTROWS ( 'Key Words' ) = 1,
COUNTX (
FILTER (
'Key Words',
SEARCH (
[Value],
SELECTEDVALUE ( 'Carrier Matrix'[OData__2_Contractcomments] ), 1, 0 ) > 0 || SEARCH ([Value],SELECTEDVALUE ( 'Carrier Matrix'[OData__8_Generalcomments] ), 1, 0 ) > 0
),
1
),
""
)
 
2021-01-07_11-46-05.png

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@StuartSmith , Did not get it completely, You can use isfiltered to check if the value is filtered

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hopefully this explains it better...

2021-01-06_16-27-10.png

 

2021-01-06_16-36-53.png

Just creating a demo file to upload.

 

Find below a link to a demo file with explaination. Hope this helps.

 

Link: https://www.dropbox.com/s/h8eo788xhadhvmx/Test%20Key%20Word%20Search%20Buttons.pbix?dl=0

 

2021-01-06_17-43-37.png

 

ok, Got it working where it displays the full table, unless a button is pressed and then displays only the button related data.

 

2021-01-07_11-11-42.png

2021-01-07_11-12-00.png

 

Just need to add an "OR" statement so it searchs 2 columns for the results, but stumped on that for the moment.

Got it working with...

 

TEST_Search_SelectValue =
IF (
COUNTROWS ( 'Key Words' ) = 1,
COUNTX (
FILTER (
'Key Words',
SEARCH (
[Value],
SELECTEDVALUE ( 'Carrier Matrix'[OData__2_Contractcomments] ), 1, 0 ) > 0 || SEARCH ([Value],SELECTEDVALUE ( 'Carrier Matrix'[OData__8_Generalcomments] ), 1, 0 ) > 0
),
1
),
""
)
 
2021-01-07_11-46-05.png

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.