Hi,
I am completely new to Alteryx and looking for some help in writing a Regex_match formula.
I am getting "Invalid type in operator== " error for below if and else statement
IF REGEX_Match([Sub Org ],':',1)="A" or REGEX_Match([Sub Org],':',1)="B" THEN ""AB
ELSEIF REGEX_Match([Sub Org],':',1)="E" THEN "S"
ELSEIF REGEX_Match([Sub Org],':',1)="65" THEN "I"
ELSEIF REGEX_Match([Sub Org],':',1)="L" AND Contains([Sub Org ],"SE") THEN "SE"
ELSEIF REGEX_Match([Sub Org],':',1)="OC" or REGEX_Match([Sub Org],':',1)="M" THEN "MC"
ELSEIF REGEX_Match([Sub Org],':',1)="W" THEN "WO"
ELSE REGEX_Match([Sub Org],':',1)
ENDIF
Kindly advise
Thank you
Hi @Nagakodali
Two things I'd check out here:
- In the first line, the result ""AB should have the quotes wrapped around the AB value
- The field this formula is applied to could also cause this error. The string results of this expression should be output to a string field.
REGEX_Match returns a true or false value so can't be compared to a string value.
REGEX_Match([Sub Org ],':',1) will return true only if [Sub Org ] is equal to :
What are you trying to achieve with these functions?
Hi,
I am trying to split the value in the suborg field and get the value before the first delimiter .I am trying to achieve below syntax in Alteryx :
IFNULL(IF SPLIT([SubOrg],':',1)='A' OR SPLIT([SubOrg],':',1)='B' THEN 'AB'
ELSEIF SPLIT([SubOrg],':',1)='E' THEN 'S'
ELSEIF SPLIT([SubOrg],':',1)='65' THEN 'I'
ELSEIF (SPLIT([SubOrg],':',1)='L' AND CONTAINS([SubOrg],'SE')) THEN 'SE'
ELSEIF (SPLIT([SubOrg],':',1)='OC' OR SPLIT([SubOrg],':',1)='M') THEN 'MC'
ELSEIF SPLIT([SubOrg],':',1)='W' THEN 'WO'
ELSE SPLIT([SubOrg],':',1) END, 'Not Found')
Kindly Suggest.
Thank you
I'd suggest something like:
IIF(CONTAINS([SubOrg],":"),
SWITCH(REGEX_Replace([SubOrg], "(.*?):.*", "$1"),
REGEX_Replace([SubOrg], "(.*?):.*", "$1"),
"A","AB",
"B","AB",
"E","S",
"65","I"
"OC", "MC",
"M", "MC",
"W", "WO"),
"Not Found")
But this doesn't cover the SE case. And am not quite sure the Not Found logic is quite right.
However this is roughly where I would start and build in those 2 cases.
If you have come sample data am happy to put together a more concrete example