The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I would like to have a Text.Contains that searches Column A for "Example" OR "Examples" OR "Examples2". I am sure it is staring me in the face but I cannot figure out how to do it.
Solved! Go to Solution.
Hi @Anonymous ,
Please try this:
if Text.Contains([Column1],"Example") = true then [Column1] else null
The function of Text.Contains will search out all the data which contains the key word. So you just need to write Text.Contains one time.
If you want to filter data, you could try this:
= Table.SelectRows(#"Changed Type", each Text.Contains([Column1], "Example"))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Put these Example(s) words you want to find in strings in lists and then use the List.MatchesAny function.
Like in the following example:
Define a table with your keywords... (Example,Examples,sample...)
Transform_Keywords_list_in_list =
Table.TransformColumns
(
Source
,{
"Keywords list"
,each Text.Split(_, ",")
}
),
Main_Data =
Table.AddColumn
(
Main_Data_Table
,"Returned_Text"
,(MAIN)=>
let
Buffered_Keywords_list_in_list = Table.Buffer(Keywords_list_in_list ),
FilteredTable = Table.SelectRows
(
Buffered_Keywords_list_in_list
,(KEYWORDS)=>
List.MatchesAny(KEYWORDS[Keywords list], each Text.Contains(MAIN[String_to_test], _, Comparer.OrdinalIgnoreCase))
),
selectValue = Table.First(FilteredTable)[Value_to_return] // or you can return directly the table... selectValue = FilteredTable
in
selectValue, type text // or if you need the table returned selectValue, type table
),
If you are trying to perform this on a table, you would like to use something like:
#"Filtered Rows" = Table.SelectRows(table, each( Text.Contains([ColumnA], "Executive") or Text.Contains([ColumnA], "General") ))
Regards
@JasonTX, thanks for the suggestion. I have been doing it that way, but I am hoping I can cut out the repetitious "Text.Contains".
Hi @Anonymous ,
Please try this:
if Text.Contains([Column1],"Example") = true then [Column1] else null
The function of Text.Contains will search out all the data which contains the key word. So you just need to write Text.Contains one time.
If you want to filter data, you could try this:
= Table.SelectRows(#"Changed Type", each Text.Contains([Column1], "Example"))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Put these Example(s) words you want to find in strings in lists and then use the List.MatchesAny function.
Like in the following example:
Define a table with your keywords... (Example,Examples,sample...)
Transform_Keywords_list_in_list =
Table.TransformColumns
(
Source
,{
"Keywords list"
,each Text.Split(_, ",")
}
),
Main_Data =
Table.AddColumn
(
Main_Data_Table
,"Returned_Text"
,(MAIN)=>
let
Buffered_Keywords_list_in_list = Table.Buffer(Keywords_list_in_list ),
FilteredTable = Table.SelectRows
(
Buffered_Keywords_list_in_list
,(KEYWORDS)=>
List.MatchesAny(KEYWORDS[Keywords list], each Text.Contains(MAIN[String_to_test], _, Comparer.OrdinalIgnoreCase))
),
selectValue = Table.First(FilteredTable)[Value_to_return] // or you can return directly the table... selectValue = FilteredTable
in
selectValue, type text // or if you need the table returned selectValue, type table
),
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
28 |
User | Count |
---|---|
106 | |
98 | |
55 | |
49 | |
48 |