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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply

filter table based on selected value using contains

Hi,

I am trying to filter the table in which column of the table contains the selected value(like substring). I am getting the selected value in the card when I select a bin of bar charts and using the same selected value to filter the table but I am getting blank rows.

Here's the bar chart by setting up the filter of Type to T1:

HIMANSHU_SINGH_0-1645033002721.png

Here's the table data:

HIMANSHU_SINGH_0-1645604495599.png

 

so if I click any of the bars of the above chart(e.g clicking "A"), I should get the below results:

HIMANSHU_SINGH_0-1645605667913.png

 

I am trying to achieve this by using the below measure:
If(CONTAINS(MAX(category_table[Category]),SELECTEDVALUE(category_table[Category])),1,0)

After this, I'll set this measure to 1 to filter out the table.
Let me what I need to do here or what I am doing wrong.

@amitchandak 

@AllisonKennedy

@ibarrau 

1 ACCEPTED SOLUTION

Hi, @HIMANSHU_SINGH 

 

You can try the following methods.

Table 2 = 
CALCULATETABLE( SUMMARIZE('Table','Table'[Category],'Table'[Value]),FILTER('Table',[Type]="T1"))

vzhangti_0-1645665418931.png

The view on the left is obtained from Table 2. Other settings remain unchanged.

vzhangti_1-1645665494683.png

 

This is the relevant document, hope to help you:

https://docs.microsoft.com/dax/search-function-dax#example-error-handling-with-search 

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

14 REPLIES 14
v-zhangti
Community Support
Community Support

Hi, @HIMANSHU_SINGH 

 

Please check the following methods.

Measure = IFERROR(SEARCH(SELECTEDVALUE(Category[Category]),SELECTEDVALUE('Table'[Category])),-1)

Put Measure in Fliters and set not equal to -1.

vzhangti_0-1645603126592.png

vzhangti_1-1645603186532.pngvzhangti_2-1645603200687.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-zhangti 

Thank you for your reply. But I don't have any category table. 

Is it possible to create the category table on the run and then use the above measure?


Hi, @HIMANSHU_SINGH 

 

So where does your A B C D come from?

 

Best Regards

Here's my main sample dataset:

HIMANSHU_SINGH_0-1645604857282.png

 


I am using this to create a chart by setting up the Type filter to T1.

Hi, @HIMANSHU_SINGH 

 

You try the following methods.

Table:

Table 2 = CALCULATETABLE( VALUES('Table'[Category]),FILTER('Table',[Type]="T1"))

vzhangti_0-1645606789137.png

Measure = IFERROR(SEARCH(SELECTEDVALUE('Table 2'[Category]),SELECTEDVALUE('Table'[Category])),-1)

vzhangti_1-1645606854311.png

Please check whether the result of this time meets your expectation?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-zhangti ,

Thanks for your solution. It's near to complete. I want to show these categories in the bar chart along with their values as I mentioned in the post.

Hi, @HIMANSHU_SINGH 

 

You can try the following methods.

Table 2 = 
CALCULATETABLE( SUMMARIZE('Table','Table'[Category],'Table'[Value]),FILTER('Table',[Type]="T1"))

vzhangti_0-1645665418931.png

The view on the left is obtained from Table 2. Other settings remain unchanged.

vzhangti_1-1645665494683.png

 

This is the relevant document, hope to help you:

https://docs.microsoft.com/dax/search-function-dax#example-error-handling-with-search 

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

In the Data Table itself, you should have a Master Category column with values of A,B,C and D.  Now create your visual/slicers.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur I don't have the Master Column with values of A,B,C,D.

So if they are in another table then one can always bring them over into your table by using the RELATED() or LOOKUPVALUE() funcion.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Yes.

lbendlin
Super User
Super User

Is the data source for your column chart a disconnected table?

I am using the same data source for both tables.

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Please show the expected outcome based on the sample data you provided.


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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