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
gco
Resolver II
Resolver II

Filter by Search Strings

Hi there,

 

I have a list of keywords and would like to filter a column account[notes] based on those keywords.  Someone helped me by giving me the calculated measure below.  And it works perfectly.  But now, i am trying to figure out how to enable SELECT ALL.  The measures below works perfectly when it is SINGLE select only.  Please help.

 

selected keywords = SELECTEDVALUE(table2[key words])

select rows =
IF (
    ISERROR ( FIND ( [selected keywords], MAX ( account[notes] ), 1, 0 ) ),
    0,
    FIND ( [selected keywords], MAX ( account[notes] ), 1, 0 )
)

 

Thank you

Glen

1 ACCEPTED SOLUTION

Hi - Apologies, should have asked for Sample Data earlier. For your case, we will need to user Loop. Please use below Measure

 

FindSearchString = 
// Get list of Selected SearchStrings Values
var SearchValues = Values(SearchStrings[SearchStringVal])
// Run a Loop to check if selected SearchStrings values are present in Comments.
var FindVal = ADDCOLUMNS(SearchValues,"Present",Find([SearchStringVal],max(LoanInfo[Comments]),1,0))
//Get Sum, it will be '0' if Comments doesn't contains any of the Selected Values else > 0
var SumTotal = sumx(FindVal,[Present])

Return SumTotal

Update PBIX file below.

http://www.mediafire.com/file/bhv7gwuyylcbq75/For_Upload_Ankit.pbix/file

 

Thanks
Ankit Jain

Do Mark it as solution if the response resolved your problem. Do Kudos the response if it seems good and helpful.

View solution in original post

12 REPLIES 12
AnkitBI
Solution Sage
Solution Sage

It's better if we know how you are planning to use this. In meantime, please try below.

FindResult = 
var SearchKey = filter(Table2,Table2[key Words] = max(Account[notes]))
var CountRows1 = CountRows(SearchKey)

return
if(CountRows1 > 0,1,0) 

Hi @AnkitBI ,

So i have a visual that displays the loan numbers and notes.  And i have a slicer with all the keywords, and it just filters the visual based on notes that matched the keywords/phrases.

 

Do i create that new measure or replace any of the 2 i already have?

Thank you 

Glen

Hi Glen,

 

You can use this Measure 'FindResults' and put in a Visual Filter pane for Base visual with Loan and Notes. Set the Visual Filter to value is '1'

Based on KeyWords selection in Slicer, base visual will only show rows which have matching KeyWords in Notes.

 

You can create a seperate measure and test it out in sepearte Visual. if it works then you can remove others.

 

Thanks,

Ankit Jain

Hi @AnkitBI ,

 

For some reason the measure you gave does not show any results.  I modified the SearchKey var and was able to get results.  But it only works on single select.  If i select more than 1 keywords, then it displays everything.

 

Measure =
var SearchKey = filter(LoanInfo, FIND(SELECTEDVALUE(SearchStrings[SearchStringVal]), MAX(LoanInfo[FraudCommentsPreview]),1,0))
var CountRows1 = CountRows(SearchKey)

return
if(CountRows1 > 0, 1, 0)

@AnkitBI 

 

The table i was working on are SearchStrings with all the keywords and LoanInfo that has the LoanNumber and Comments that i wanted to filter.

Thank you

Glen

Pls share sample data of both the tables.

Hi - Apologies, should have asked for Sample Data earlier. For your case, we will need to user Loop. Please use below Measure

 

FindSearchString = 
// Get list of Selected SearchStrings Values
var SearchValues = Values(SearchStrings[SearchStringVal])
// Run a Loop to check if selected SearchStrings values are present in Comments.
var FindVal = ADDCOLUMNS(SearchValues,"Present",Find([SearchStringVal],max(LoanInfo[Comments]),1,0))
//Get Sum, it will be '0' if Comments doesn't contains any of the Selected Values else > 0
var SumTotal = sumx(FindVal,[Present])

Return SumTotal

Update PBIX file below.

http://www.mediafire.com/file/bhv7gwuyylcbq75/For_Upload_Ankit.pbix/file

 

Thanks
Ankit Jain

Do Mark it as solution if the response resolved your problem. Do Kudos the response if it seems good and helpful.

Hi @AnkitBI ,

 

Thanks again for providing the solution to my problem.  If i may ask another question, how do you create a measure to count the number of rows selected?  I have been playing around with the measures, but could not figure out an accurate way of doing it.

Thank you

Glen

Hi @AnkitBI ,

You can disregard my previous question about counts.  I figured it out.  RowsCount = COUNTROWS(FILTER(LoanInfo, [FindSearchString] > 0))

 

Thanks

Glen

Hi @AnkitBI ,

You are a genius!!! where do you guys learn all these stuff?  I go on powerbi classes but they never touch on these topics or come close to any advanced DAX queries.

 

Your measure works perfectly for what i was trying to do.  Thank you again for taking the time to share the answer!!!

Glen

Hi @AnkitBI 

 

I am going to upload a stripped down pbix file shortly.

Thank you

 

Glen

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.

Top Solution Authors
Top Kudoed Authors