Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi!
My goal is to write a function that basically answers, If the title contains any of the following words, then Y
Specific example: the title is "Supergoop! Unseen Sunscreen SPF 40, Reef-Friendly Face Sunscreen for All Skin Types"
If the title contains any of the following words, I'd want the column value to be "Y" (yes). If not, then "N".
- reef safe, reef-friendly, reef friendly, reef-safe, coral reef
So, the value here would be "Y"
Any suggestions??
Thank you so much!
Solved! Go to Solution.
@allieg2830 you can write a dynamic measure like this if you have two tables, one for the lookup value and one for the string, without needing to hardcode. Pbix is attached
The same expression doubles as a calculated column
Measure =
VAR _lookup =
MAXX (
FILTER (
CROSSJOIN ( VALUES ( t1[Column1] ), VALUES ( t2[LookupValue] ) ),
CONTAINSSTRING ( [Column1], [LookupValue] )
),
[LookupValue]
)
RETURN
IF ( _lookup <> BLANK (), "Y", "N" )
@allieg2830 you can write a dynamic measure like this if you have two tables, one for the lookup value and one for the string, without needing to hardcode. Pbix is attached
The same expression doubles as a calculated column
Measure =
VAR _lookup =
MAXX (
FILTER (
CROSSJOIN ( VALUES ( t1[Column1] ), VALUES ( t2[LookupValue] ) ),
CONTAINSSTRING ( [Column1], [LookupValue] )
),
[LookupValue]
)
RETURN
IF ( _lookup <> BLANK (), "Y", "N" )
@allieg2830 Note that this checks the entire column t1[Column1] at once. If you only want to check for keywords one row at a time, then it can be simplified a bit.
Column1ContainsKeyword =
VAR _matchingKeywords =
FILTER ( VALUES ( t2[keyword] ), CONTAINSSTRING ( t1[Column1], t2[keyword] ) )
RETURN
IF ( ISEMPTY ( _matchingKeywords ), "N", "Y" )
Hi @allieg2830 ,
You can create a column using below code:-
Column 2 =
SWITCH (
TRUE (),
CONTAINSSTRING ( Contains_specific_string[column], "reef-friendly" ), "Y",
CONTAINSSTRING ( Contains_specific_string[column], "reef safe" ), "Y",
CONTAINSSTRING ( Contains_specific_string[column], "reef friendly" ), "Y",
CONTAINSSTRING ( Contains_specific_string[column], "reef-safe" ), "Y",
CONTAINSSTRING ( Contains_specific_string[column], "coral reef" ), "Y",
"N"
)
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
User | Count |
---|---|
13 | |
10 | |
8 | |
7 | |
5 |
User | Count |
---|---|
24 | |
16 | |
15 | |
10 | |
7 |